SELECT xxmc,sname as xsxm,sex,phone,address jzdz FROM student s LEFT JOIN xxjbxx x ON x.sid = s.sid 此处的s为student表的别名,x为xxjbxx表的别名,xsxm是sname学生姓名的别名,jzdz是学生地址的别名 ps: (1)表的别名要在from子句中指定,并且别名位于查询中其余列之前 (2)使用表的别名可以减少查询中输入的文本的数量,并且可能还会减少在输入过程中的错误. 2.给字段起别…
行转列:源表: 方法1:case when select y,sum(case when q=1 then amt end) q1,sum(case when q=2 then amt end) q2,sum(case when q=3 then amt end) q3,sum(case when q=4 then amt end) q4from test04 group by y; 效果: 方法2:decade(decode(字段,v1(字段值或运算后的值),retu1(字段值或运算后的值与v…
for Example: select date_format(date,'%Y-%m-%d') as day, count(case when xinghao='a' then 1 end) as 'A', count(case when xinghao='b' then 1 end) as 'B', count(case when xinghao='c' then 1 end) as 'C' from table group by day.…
--Type CREATE OR REPLACE TYPE zh_concat_im AUTHID CURRENT_USER AS OBJECT ( CURR_STR clob, STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT zh_concat_im) RETURN NUMBER, MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT zh_concat_im, P1 IN VARCHAR2)…
--场景1: A B a a a b b 希望实现如下效果: a ,, b , create table tmp as B from dual union all B from dual union all B from dual union all B from dual union all B from dual; .方法1:listagg --listagg() + group by: 推荐使用 select a,listagg(b,',') within group (order by…
1.修改数据表名 ALTER TABLE [表名.]OLD_TABLE_NAME RENAME TO NEW_TABLE_NAME; 2.修改列名 ALTER TABLE [表名.]TABLE_NAME RENAME COLUMN OLD_COLUMN_NAME TO NEW_COLUMN_NAME; 3.修改列的数据类型 ALTER TABLE [表名.]TABLE_NAME MODIFY COLUMN_NAME NEW_DATATYPE; 4.插入列 ALTER TABLE [表名.]TAB…
分页查询中,需要用到伪列rownum,代码如下: select * from (select rownum rn, name from cost where rownum <= 6) where rn >3; 可是第一次用rownum,第二次用rn,位置不能变,否则出错,第一次的rownum是oracle中的一个虚拟列,rn是给这个rownum起的别名,也就是在子查询中的别名要在外查询中调用.需要注意一下,就是rownum是取出一个再编号, 所以在里面我们可以写<或者<=,而不能写…
Oracle中对列加密的方法 2011-12-22 17:21:13 分类: Linux Oracle支持多种列加密方式: 1,透明数据加密(TDE):create table encrypt_col(id int,txt varchar2(100) encrypt using '算法名称' identified by '密钥' no salt);优点:对应用完全透明缺点:需要数据库管理员管理wallet,增加了管理复杂性,也无法避免数据库管理员查看原文. 2,使用DBMS_CRYPTO包优点:…
1.Mysql update语句赋值嵌套select 点击(此处)折叠或打开 update a set col=(select col from a where id='5') where id>5 and id<10; 报错了 ERROR 1093 (HY000): You can't specify target table 'a' for update in FROM clause 经过研究 发现是 mysql 定义update语句不能同时对同一张进行set 赋值操作,也就是说 upd…
查询分区:Select *From user_extents WHERE partition_name='分区名'; 1)创建表空间 create tablespace HRPM0 datafile '/oradata/misdb/HRPM0.DBF' size 5m autoextend on next 10m maxsize unlimited 2)删除表空间(同时把数据文件也删除) DROP TABLESPACE data01 INCLUDING CONTENTS AND DATAF…