Shrink the Oracle tablespace physical file

Source: Internet
Author: User
In Oracle, there are often situations in which a table space is too large due to misoperation. The Delete method does not clear the high watermark, after using truncate, although the high watermark has been cleared, but the expanded table space does not shrink, it should be reduced by the following method:

1. Find the data file ID for the table space, taking the users table space as an example:

Select file_id from dba_data_files where tablespace_name = ' USERS '

2. Allow table space to shrink (dissolve table space):

Alter TABLESPACE users COALESCE;

3. Query the table space for the size of the table, to determine which table to operate:

SELECT * from dba_segments where tablespace_name= ' USERS ' and segment_type= ' TABLE '

4. Allow the table to move rows (some tables cannot be truncate, only delete)

ALTER TABLE test row movement;

5. High watermark Recovery for the table:

ALTER TABLE test shrink space;

6. Finally, the data file ID of the first step is compressed (resize), the size must be greater than the size used:

ALTER DATABASE datafile 4 resize 2000M;

After the above operation, the enlarged table space can be shrunk back to normal size, the pro-test is available!

Shrink the Oracle tablespace physical file

Related Article

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.