|
查看表是否被锁也会经常用到,有时同事共用一直数据库的时候,可能都在对某个表进行操作,一个人对表锁定之后,我们再进行for update表就是卡起来,所以在执行for update前可以先查看表是否被锁.
1、查看表空间使用情况
SELECT B.FILE_ID,
B.TABLESPACE_NAME ,
B.FILE_NAME,
B.BYTES / 1024 / 1024,
(B.BYTES - SUM(NVL(A.BYTES, 0))) / 1024 / 1024,
SUM(NVL(A.BYTES, 0)) / 1024 / 1024,
SUM(NVL(A.BYTES, 0)) / (B.BYTES) * 100
FROM DBA_FREE_SPACE A, DBA_DATA_FILES B
WHERE A.FILE_ID = B.FILE_ID www.2cto.com
GROUP BY B.TABLESPACE_NAME,
B.FILE_NAME,
B.FILE_ID,
B.BYTES
ORDER BY B.TABLESPACE_NAME;
2、给表空间添加数据文件
alter tablespace 空间名 add datafile
'/dev/rdata_1g_21' size 1000M autoextend off,
'/dev/rdata_1g_25' size 1000M autoextend off,
'/dev/rdata_1g_22' size 1000M autoextend off;
3、查看某表是否被锁
select c.inst_id, b.object_name, a.session_id, c.serial#, c.machine,
c.PROGRAM,c.username,c.status, c.osuser, c.logon_time ,a.*
from gv$locked_object a, dba_objects b, gv$session c
where a.object_id=b.object_id and b.object_name='TOAD_PLAN_TABLE'
and c.sid=a.session_id and schemaname<>'SYS' ;
|
|