oracle中常见的查询操作

 

普通查询:
select * from t;


去除重复值:
select distinct f1,f2 from t;


between用法:
select * from t where f1 not/between 1and 2;


like用法:
select * from t where f1 not/like '_MDB%';


in用法:
select * from t where f1 not/in (n1,n2..);


显示前5行:
select * from t where rownum<=5;


顺序/倒序排列:
select * from t order by f1,f2 asc/desc;


按照字段求和:
select sum(f2) from t1 group by f1;
联合多表时使用having代替where:
having avg(f1)>50;


合并俩个列显示:
select f1||':'||f2 as f12 from t;


备份表数据:
create table t2 as select * from t1;


从其他表插入数据:
insert into t2 select * from t2;


求某列平均数:
select avg(f1) from t1;


求行数:
select count(*/f1) from t1;


求最大/最小值:
select max/min(f1) from t1;


浮点型数据四舍五入:
select round(f5,2) from t1;


数据加入:
select *from t1 inner/left/right/full join t2 on t1.f1=t2.f2;


数据联合(俩个表列数需相同):
select f1,f4 fromt1 union select f1,f2 from t2;


数据截取:
select substr(f1,1,3) from t1;
update t1 set f1=substr(f2,1,3)||'say'||substr(f3,7);

 

转载于:https://www.cnblogs.com/watertaro/p/9220769.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值