--查看被鎖住的表 select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id; ----查看被鎖住的會話 select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time; --查看被阻塞的會話 select * from dba_waiters; --查看引起死鎖的會話 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 order by ao.object_name ; --釋放鎖或者殺掉ORACLE進程 alter system kill session sid,.serial#
--查看表空間大小和使用率 select a.tablespace_name, total, free, total-free as used, substr(free/total * 100, 1, 5) as "FREE%", substr((total - free)/total * 100, 1, 5) as "USED%" from (select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b where a.tablespace_name = b.tablespace_name order by a.tablespace_name; --某張表對應的數據庫實例和表空間 select owner,table_name,tablespace_name from dba_tables where table_name='BILLS_BREAK'; --表空間下所表 select table_name from dba_tables where tablespace_name='USERS'; --表空間擴容 --1.先查詢表空間在物理磁盤上存放的位置 SELECT tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space FROM dba_data_files where tablespace_name='USERS' ORDER BY tablespace_name ; --2.改變數據文件的大小 alter database datafile '/oracle/app/oradata/mytablespace/my_01.dbf' resize 256M; --3.驗證 select bytes/1024/1024, tablespace_name from dba_data_files where tablespace_name='USERS';