`

oracle 一些有用的sql

 
阅读更多

--锁表及杀锁表进程语句
select sess.sid,
    sess.serial#,
    lo.oracle_username,
    lo.os_user_name,
    ao.object_name,
    lo.locked_mode
    from v$locked_object lo,
    dba_objects ao,
    v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

alter system kill session '416,24917';

--查外键的父表
select t.table_name from user_constraints t
where t.constraint_type='R' and t.r_constraint_name
in(
select s.constraint_name from user_constraints s
where s.table_name='主表名' and s.constraint_type='P')

--查询表空间使用情况的脚本
select df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
"Pct. Free"
from
(select tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from dba_data_files
group by tablespace_name) df,
(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name
from dba_segments
group by tablespace_name) tu
where df.tablespace_name = tu.tablespace_name

 

--查询数据库的编码和语言等各种信息
  select * from v$nls_parameters;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics