Does Truncate table remove the corresponding LOB segments for the tables at the same time? --Not

Source: Internet
Author: User

Test one: rhel5; ora10203

Sql> create user Lixora identified by Lixora default tablespace users;

User created.

Sql> Grant DBA to Lixora;
Grant succeeded.


Sql> Conn Lixora/lixora
Connected.
Sql> Select COUNT (*) from user_segments;
COUNT (*)
----------
0


Sql> CREATE TABLE t (x CLOB);
Table created.


Sql> select * from V$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0-64bi
PL/SQL Release 10.2.0.3.0-production
CORE 10.2.0.3.0 Production
TNS for Linux:version 10.2.0.3.0-production
Nlsrtl Version 10.2.0.3.0-production


Sql> Select Segment_name, Segment_type, bytes
2 from User_segments;

Segment_name Segment_type BYTES
--------------------------------------------------------------------------------- ------------------ ----------
sys_il0000085497c00001$$ Lobindex 65536-----Initial Score With size
sys_lob0000085497c00001$$ lobsegment 65536
TTABLE 65536


sql> sql> insert INTO T select Lpad (segment_name,8192) from dba_segments; ----Inserting test data
4780 rows created.

Sql> commit;
Commit complete.


Sql> Select Segment_name, Segment_type, bytes
2 from User_segments;

Segment_name Segment_type BYTES
--------------------------------------------------------------------------------- ------------------ ----------
sys_il0000085497c00001$$ Lobindex 65536
sys_lob0000085497c00001$$ lobsegment 40894464
TTABLE 327680

------TRUNCATE TABLE
sql> truncate TABLE t;
Table truncated.


Sql> Select Segment_name, Segment_type, bytes
2 from User_segments;
Segment_name Segment_type BYTES
--------------------------------------------------------------------------------- ------------------ ----------
sys_il0000085497c00001$$ Lobindex 65536
sys_lob0000085497c00001$$ lobsegment 65536-------LOB The segment space has been freed, but the LOB segment still exists
TTABLE 65536

-------try to reclaim LOB segment space manually
Sql> ALTER TABLE T modify LOB (x) (shrink space);
Table altered.


Sql> Select Segment_name, Segment_type, bytes
2 from User_segments;


Segment_name Segment_type BYTES
--------------------------------------------------------------------------------- ------------------ ----------
sys_il0000085497c00001$$ Lobindex 65536 ----- --lob segment still exists
sys_lob0000085497c00001$$ lobsegment 65536 ------LOB segments are still exists

TTABLE 65536


The version of Oracle 11g is tested in the same situation as above.

Summarize:

If the table contains LOB fields at TRUNCATE TABLE, the corresponding log segment will not be cleaned up, but the space will be reclaimed.


Does Truncate table remove the corresponding LOB segments for the tables at the same time? --Not

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.