SQL> alter session set tracefile_identifier='10046';
SQL> alter session set events '10046 trace name context forever,level 12'; ---开启10046事件
Session altered.
SQL>
SQL> alter table test_emp modify partition pt_1 deallocate unused; ---执行该命令释放子分区未被使用的空间;
Table altered.
SQL> alter session set events '10046 trace name context off'; ---关闭10046事件
Session altered.
SQL> select value from v$diag_info where;
VALUE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/opt/oracle/diag/rdbms/dbs/dbs/trace/dbs_ora_3263_10046.trc
⑦:验证空间是否被释放:
SQL> select B.SEGMENT_NAME, B.blocks,B.blocks * 8096 / 1024 / 1024, A.BLOCKS,A.blocks * 8096 / 1024 / 1024, A.EMPTY_BLOCKS from user_tables a, USER_SEGMENTS B WHERE TABLE_NAME = 'TEST_EMP' AND A.TABLE_NAME = B.SEGMENT_NAME;
SEGMENT_NAME BLOCKS B.BLOCKS*8096/1024/1024 BLOCKS A.BLOCKS*8096/1024/1024 EMPTY_BLOCKS
--------------------------------------------------------------------------------- ---------- ----------------------- ---------- ----------------------- ------------
TEST_EMP 1024 7.90625 46 .355163574 0
SQL> SELECT segment_name, SUM(bytes) / 1024 / 1024 Mbytes FROM dba_segments WHERE PARTITION_NAME = 'PT_1' GROUP BY segment_name;
SEGMENT_NAME MBYTES
--------------------------------------------------------------------------------- ----------
TEST_EMP 16
BIN$VibHVCPfDL/gU8gCqMDDfw==$0 8
------------------------------ ------------ ---------- ---------- ---------- -------------------
SYSAUX 94.44 510 28.38 481.63 2017-08-07 17:19:30
SYSTEM 93.24 800 54.06 745.94 2017-08-07 17:19:30
USERS 26.25 5 3.69 1.31 2017-08-07 17:19:30
UNDOTBS1 5.73 470 443.06 26.94 2017-08-07 17:19:30
TEST .05 20480 20470 10 2017-08-07 17:19:30