oracle檢視錶空間使用情況及某表是否被鎖的問題

zangqianglei發表於2015-05-06

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

    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' ;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25954236/viewspace-1625744/,如需轉載,請註明出處,否則將追究法律責任。

相關文章