Oracle tablespace reduction

Source: Internet
Author: User

Oracle will inevitably have no space to recycle when it is used to shrink the tablespace database. If the space is too large, use the following method to recycle it. Query the space occupied by a table: [SQL] SELECT tablespace_name, 100 * (sum_max-sum_alloc + nvl (sum_free, 0)/sum_max AS capa_per, (sum_max-sum_alloc + nvl (sum_free, 0)/1024/1024 AS capa_free, (sum_alloc-nvl (sum_free, 0)/1024/1024 as capa_used, sum_max/1024/1024 as capa_max, 100 * nvl (sum_free, 0) /sum_alloc As per, nvl (sum_free, 0)/1024/1024 as free, (sum_alloc-nvl (sum_free, 0)/1024/1024 as used, sum_alloc/1024/1024 as max FR OM (SELECT tablespace_name, sum (bytes) AS sum_alloc, sum (decode (maxbytes, 0, bytes, maxbytes) AS sum_max FROM dba_data_files group by tablespace_name), (SELECT tablespace_name AS fs_ts_name, sum (bytes) AS sum_free FROM dba_free_space group by tablespace_name) WHERE tablespace_name = fs_ts_name (+) order by 2 and 3; MAX is the disk space currently occupied (unit: MB ), USED is the actual space required for data. FREE is the space that can be recycled. Assume that the SYSTEM table MAX is 10240 M, USED is 600 M, and data is stored in the D: \ ORADATA \ DBA directory. Use the following command to reduce the SYSTEM tablespace to 610 M: [SQL] alter database datafile 'd: \ ORADATA \ DBA \ system01.dbf' resize 610 m; other tablespace (such as UNDOTBS1 and INDX) methods are the same.
 

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.