Oracle 11g Release 2 patch 2 ( 11.2.0.2) introduced "Enhanced Truncate " Functionality , by which you can release all
the storage when you truncate the table .
Please see below for example.
SQL> select * from v$version ;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> create table t as select object_id , object_name from all_objects;
Table created.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
3
SQL> truncate table t;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
.0625
SQL> drop table t purge;
Table dropped.
SQL> create table t as select object_id , object_name from all_objects;
Table created.
SQL> truncate table t drop storage ;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
.0625
SQL> drop table t purge;
Table dropped.
SQL> create table t as select object_id , object_name from all_objects;
Table created.
Let us use 'drop all storage ' clause with the TRUNCATE .
SQL> truncate table t drop all storage ;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
SQL> Select count(*) from user_segments where segment_name ='T';
COUNT(*)
----------
0
As you can see , there is no storage associated with the table 'T' .
Comments Welcome.
the storage when you truncate the table .
Please see below for example.
SQL> select * from v$version ;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> create table t as select object_id , object_name from all_objects;
Table created.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
3
SQL> truncate table t;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
.0625
SQL> drop table t purge;
Table dropped.
SQL> create table t as select object_id , object_name from all_objects;
Table created.
SQL> truncate table t drop storage ;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
.0625
SQL> drop table t purge;
Table dropped.
SQL> create table t as select object_id , object_name from all_objects;
Table created.
Let us use 'drop all storage ' clause with the TRUNCATE .
SQL> truncate table t drop all storage ;
Table truncated.
SQL> select sum(bytes)/1024/1024 from user_segments where segment_name ='T';
SUM(BYTES)/1024/1024
--------------------
COUNT(*)
----------
0
As you can see , there is no storage associated with the table 'T' .
Comments Welcome.
No comments:
Post a Comment