ORACLE系统查询语句
ORACLE系统查询语句1、序列:select * from dba_sequences;2、视图:select * from dba_views;select * from all_views;3、查询表名、列名、标注释: 这个比较实用,可以用于导出数据时,不用再去写一张静态数据来存储。select * from user_col_comments;指当前这个用户下的表select * from all_col_comments;所有select * from dba_col_comments; 具备DBA权限的4 查看某表的创建时间select object_name,created from user_objects where object_name=upper('&table_name');5 查看某表的大小select sum(bytes)/(1024*1024) as "size(M)" from user_segmentswhere segment_name=upper('&table_name');6 查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select * from peoplewhere peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)7 删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录delete from peoplewhere peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)8 查找表中多余的重复记录(多个字段)select * from vitae awhere (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)9 删除表中多余的重复记录(多个字段),只留有rowid最小的记录delete from vitae awhere (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)10 1.GRANT 赋于权限常用的系统权限集合有以下三个:CONNECT(基本的连接), RESOURCE(程序开发), DBA(数据库管理)常用的数据对象权限有以下五个:ALL ON 数据对象名, SELECT ON 数据对象名, UPDATE ON 数据对象名,DELETE ON 数据对象名, INSERT ON 数据对象名, ALTER ON 数据对象名GRANT CONNECT, RESOURCE TO 用户名;GRANT SELECT ON 表名 TO 用户名;GRANT SELECT, INSERT, DELETE ON表名 TO 用户名1, 用户名2;2.REVOKE 回收权限REVOKE CONNECT, RESOURCE FROM 用户名;REVOKE SELECT ON 表名 FROM 用户名;REVOKE SELECT, INSERT, DELETE ON表名 FROM 用户名1, 用户名2;表名为 dept ,其中name字段是中文,下面分别实现按照单位名称的笔划、部首和拼音排序。1: //按照笔划排序2: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M');3: //按照部首排序4: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_RADICAL_M');5: //按照拼音排序,此为系统的默认排序方式6: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M'); 注意,该SQL指令并非标准指令,在SQLServer下面的实现方式并不相同。optimizer_cost 值越大影响越大./* 查询锁 */SELECT /*+ ordered */o.object_name, o.object_type, l.locked_mode, s.machine, l.os_user_name,s.terminal, l.oracle_username, o.subobject_name, s.program, s.moduleFROM v$session s, v$locked_object l, dba_objects oWHERE l.object_id = o.object_idAND s.sid = l.session_id/* 查询锁 */SELECT /*+ ordered */o.object_name, o.object_type, k.type, l.locked_mode lock_mode_value,DECODE(l.locked_mode, 0, 'NONE',1, 'NULL',2, 'ROW SHARE',3, 'ROW EXCLUSIVE',4, 'SHARE',5, 'SHARE ROW EXCLUSIVE',6, 'EXCLUSIVE') lock_mode,s.sid, s.serial#,s.machine, l.os_user_name, s.terminal, l.oracle_username, o.subobject_name,s.program, s.moduleFROM v$session s, v$locked_object l, v$lock k, dba_objects oWHERE l.object_id = o.object_idAND s.sid = l.session_idAND s.sid = k.sidORDER BY s.sid/* 查询事务中的锁和相关信息 */SELECT /*+ ordered */o.object_name, o.object_type,k.type, l.locked_mode, s.machine, l.os_user_name,s.terminal, l.oracle_username, o.subobject_name, s.program, s.module,k.id1, k.id2, k.request, k.ctime, k.block,t.status, t.start_time, t.xidusn seg_num, r.name seg_nameFROM v$rollname r, v$lock k, v$session s, v$locked_object l, dba_objects o,v$transaction tWHERE l.object_id = o.object_idAND s.sid = l.session_idAND s.sid = k.sidAND t.xidusn = r.usnAND l.xidusn = t.xidusn/* 缓冲区命中率 *//* The data in V$SYSSTAT reflects the logical and physical reads for all buffer poolswithin one set of statistics *//* 50%以下(危险,立即增加缓冲区缓存) 95%以上分配过度 90%-95%为调整的目标 */SELECT ROUND((1 - (phy.value / (cur.value + con.value))) * 100,3) || '%' "Buffer Cache Hit Ratio"FROM v$sysstat phy, v$sysstat cur, v$sysstat conWHERE phy.name = 'physical reads'AND cur.name = 'db block gets'AND con.name = 'consistent gets'/* 每个Buffer Pool的命中率 */上一个:oracle记录被另一个用户锁住怎么办
下一个:oracle表数据误删还原
- 更多Oracle疑问解答:
- 运行exp备份oracle数据库提示oracle-12154错误
- 有没有,生产Oracle Rman 备份脚本的工具啊!
- 初学orcle,希望有大大帮忙解说一下详细步骤,从登录oracle到创建表的过程
- oracle语句问题:一张user表,三个字段,id,name,time,插入记录比如:张三2007,李四2008,张三2011
- 如何写一个ORACLE触发器同步两个表中的数据?
- oracle 如何查看一个服务器上有多少个数据库.
- oracle 创建包的时候错误 求解
- oracle 重复列的问题
- oracle 中如何查处2星期前的数据
- 请教oracle数据库安装中的问题
- 请问谁能提供给我标准的oracle ERP的数据库表结构并详细说明各表主要的作用?
- 安装oracle遇到的问题 invalid entry CRC (expected 0x3e12e795 but got 0x9db0e9fd)
- 我的是ORACLE 10G,在RMAN中如何按指定的时间恢复数据文件啊?
- oracle为什么没有自动增长列
- oracle快捷键都有哪些啊?