Oracle tablespace reduction

Source: Internet
Author: User

If the database has been used for a long time, there will inevitably be no space to recycle. If the space is too large, you can use the following method to recycle it.

The space occupied by the query tables:

 
Selecttablespace_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 maxfrom (select tablespace_name, sum (bytes) as sum_alloc, sum (decode (maxbytes, 0, bytes, maxbytes) as sum_maxfrom dba_data_filesgroup by tablespace_name), (select tablespace_name as fs_ts_name, sum (bytes) as sum_freefrom created by tablespace_name) where tablespace_name = fs_ts_name (+) order by 2, 3;

Max is the disk space currently occupied (unit: MB), used is the actual space required for data, and free is the available space.

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:

 
Alter database datafile 'd: \ oradata \ DBA \ system01.dbf' resize 610 m;

Other tablespace (such as undotbs1 and indx) methods are the same.

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.