-- 查看數據庫的存儲過程 select * from user_procedures ;sql
-- 得到全部的表名稱 select * from user_tab_comments ; -- 查看數據庫的存儲過程 select * from user_procedures ; -- 查看存儲過程的內容 select text from user_source where name = 'GETCOMCODE' ;數據庫
-- 查全部的表 select * from user_tables ; -- 查全部的索引 select * from user_indexs ;session
查詢用戶表的索引(非彙集索引): select * from user_indexes where uniqueness = 'NONUNIQUE ' 查詢用戶表的主鍵(彙集索引): select * from user_indexes where uniqueness = 'UNIQUE 'oracle
--查找死鎖的進程: SELECT s.username, l.OBJECT_ID, l.SESSION_ID, s.SERIAL#, l.ORACLE_USERNAME, l.OS_USER_NAME, l.PROCESS FROM V$LOCKED_OBJECT l, V$SESSION S WHERE l.SESSION_ID = S.SID;索引
--查詢發生死鎖的select語句進程
select sql_text from v$sql where hash_value in (select sql_hash_value from v$session where sid in (select session_id from v$locked_object))內存
--kill掉這個死鎖的進程: alter system kill session 'sid,serial#';terminal
select t2.username,t2.sid,t2.serial#,t2.logon_time,t3.sql_text from v$locked_object t1,v$session t2,v$sqltext t3 where t1.session_id=t2.sid and t2.sql_address=t3.address --and t3.sql_text like 'update%' order by t2.logon_time;hash
--查詢鎖表語句 SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,io
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial# ;
數據庫io最大的sql
-查看內存 free -m -查看CPU使用狀況top -查看磁盤空間使用率 df -h
--查看數據庫鏈接數。
select num_rows * avg_row_len from user_tables where table_name = 'SAREALPAYFEE'
select count() from v$session; select count() from v$process; select value from v$parameter where name ='processes'; select count(*) from v$session where status='ACTIVE';