您的位置:首页 > 数据库 > Oracle

常用oracle数据库查询命令

2017-12-04 09:05 381 查看
(1)Select * from tables(表名);  //查询表tables的内容
(2)Truncate table tables(表名);//清除表内数据;但保留格式
(3)Select  ID(列名)from tables  groupby
ID(列名)、ID2(列名)havingcount(*)>1; //查询表中重复的数据
(4)Select * from tables(表名) a where a.id(列名)=’07552223’(重复的数据);//将在列ID中所有与07552223相同的数据排列出来
(5)delete from tables where rowid in (select min(rowid)fromtables where id=’15252525’) group by username);  //删除table表中ID列数据为‘15252525’的重复项
(6)delete from table where rowid in(select min(rowid)fromtable group by id..id2);  //删除表table中所有关于列(ID)的重复信息
(7)select * from tables where regex_like(id,’^[^[:digit:
]]+$’);    //查询table在id列中所有是数字的数据
  (8)select* from tables where regex_like(id,’^([a-z]|[A-Z]+[0-9]
+)$’);          
//查询table在id列中所有带有字符和数字的数据
(9)select count(*)fromtables; //查询table中所有数据的行数
(10)select table_name from xxcj_tj_zdcj a group by a.table_
namecount(*) >1; //查询数据库xxcj_tj_zdcj中是否有重复的表
(11)select * from xxcj_tj_zdcj awhere a.table_name in (‘05255’) order by a.table_name for update;  //修改数据库xxcj_tj_zdcj中的值(即括号内的内容)
(12)select * from xxcj_tj_zdcj awhere a.id=’’ for update;//修改数据库xxcj_tj_zdcj中id列的内容
(13)truncate table数据库;   //数据比对 

(14)select t.* ,t.rowid from 表名 t; //编辑表

(15)alter table 表名 add 列名 字符类型;//新建列
(16)alter table 表名 modify 列名 字符类型;//修改列类型
(17)alter table 表名 drop column 列名;//删除列(最后一列)
(18)select * from 表名 where asciistr(列名)not like ‘%\%’;//查询数据表中xx列中的为中文字符的数据
(19)select  substr(f_get_sfzhm18(zjhm) ,7,8)as csrq from 表名where regexp_like(substr(f_get_sfzhm18(zjhm) ,7,1) ,’[^1[2]’);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: