oracle常用sql查询语句
上一篇 /
下一篇 2013-06-07 15:27:03
/ 个人分类:资料
1、查询前100条记录
select t.id,t.name from table1 t where t.type<>'test' and rownum<101
2、查询列不重复的行内容
select distinct(type) from table1;
3、查询不重复记录的个数
select count(distinct t.name) from table1 t;
4、查询列col长度小于5的行
select col from table1 where length(col)<5;
5、查询列中不全为英文字符的行
select col from table1 where length(col)!=lengthb(col);
6、查询不同状态及其个数
select status,count(status) from table1 group by status;
7、查询3种状态的记录
select * from table1 where status in('pending','running','succeeded');
8、查询当前时间
select sysdata from dual;
9、查询某天的数据并降序排列
select * from table1 t where to_char(time,'yyyy-MM-dd')='2012-05-11' order by t.time desc
10、左外连接
select t.*,u.* from role t left outer join tb_user u on t.userid=u.id left outer join tb_role r on t.roleid=r.id;
正则表达式匹配
11、列name以“北京”“深圳””上海“开头的记录
select * from table1 where regexp_like(name,'^(北京|上海|深圳)')
12、显示当前连接用户
show user
13、连接字符串
select concat(col1,col2) from table1;
查询当前用户所有表名
select unique tname from col;
查看那些用户在使用数据库
select username from v$session;
查看用户从那台机器登陆oracle
select machine,terminal from v$session;
查看系统被锁的事务时间
select * from v$locked_object;
更多,http://www.doc88.com/p-85056852755.html
收藏
举报
TAG: