Oracle Data File shrinking

Source: Internet
Author: User

Oracle Data files shrink with the use of the database, the data files become larger and larger. Is there a way to squeeze out the relevant table from the block marked as free: www.2cto.com DBA_DATA_FILESDBA_DATA_FILES describes database files. column Datatype NULL DescriptionFILE_NAME VARCHAR2 (513) Name of the database fileFILE_ID number not null File identifier number of the database fileTABLESPACE_NAME VARCHAR2 (30) not null Name of the tablespace to which the file belongsBYTES NUMBER Size of the file in bytesBLOCK S number not null Size of the file in Oracle blocksSTATUS VARCHAR2 (9) File status: AVAILABLE or INVALID (INVALID means that the file number is not in use, for example, a file in a tablespace that was dropped) RELATIVE_FNO NUMBER Relative file numberAUTOEXTENSIBLE VARCHAR2 (3) Autoextensible serial NUMBER Maximum file size in bytesMAXBLOCKS NUMBER Maximum file size in blocksINCREMENT_BY NU MBER Number of Oracle blocks used as autoextension incrementUSER_BYTES NUMBER The size of the file available for user data. the actual size of the file minus the USER_BYTES value is used to store file related metadata. USER_BLOCKS NUMBER Number of blocks which can be used by the dataONLINE_STATUS VARCHAR2 (7) Online status of the file: SYSOFFSYSTEMOFFLINEONLINERECOVER www.2cto.com DBA_FREE_SPACEDBA_F REE_SPACE describes the free extents in all tablespaces in the database. note that if a datafile (or entire tablespace) is offline in a locally managed tablespace, you will not see any extent information. if an object has extents in an online file of the tablespace, you will see extent information about the offline datafile. however, if the object is entirely in the offline file, a query of this vi Ew will not return any records. related ViewUSER_FREE_SPACE describes the free extents in the tablespaces accessible to the current user. column Datatype NULL DescriptionTABLESPACE_NAME VARCHAR2 (30) Name of the tablespace containing the extentFILE_ID NUMBER File identifier number of the file containing the extentBLOCK_ID NUMBER Starting block number of the extentBYTES NUMBER Size of the extent (in B Ytes) -- free bytesBLOCKS NUMBER Size of the extent (in Oracle blocks) -- free blockRELATIVE_FNO NUMBER Relative file number of the file containing the extent DBA_EXTENTSDBA_EXTENTS describes the extents comprising the segments in all tablespaces in the database. note that if a datafile (or entire tablespace) is offline in a locally managed tablespace, you will not see any extent information. if an o Bject has extents in an online file of the tablespace, you will see extent information about the offline datafile. however, if the object is entirely in the offline file, a query of this view will not return any records. related ViewUSER_EXTENTS describes the extents comprising the segments owned by the current user's objects. this view does not display the OWNER, FILE_ID, BLOCK_ID, orRELATIVE_FNO Columns. column Datatype NULL DescriptionOWNER VARCHAR2 (30) Owner of the segment associated with the extentSEGMENT_NAME VARCHAR2 (81) Name of the segment associated with the extentPARTITION_NAME VARCHAR2 (30) object Partition Name (Set to NULL for non-partitioned objects) SEGMENT_TYPE VARCHAR2 (18) Type of the segment: index partition, TABLE PARTITIONTABLESPACE_NAME VARCHAR2 (30) Name of the tablespace Containing the extentEXTENT_ID NUMBER Extent number in the segmentFILE_ID NUMBER File identifier number of the file containing the extentBLOCK_ID NUMBER Starting block number of the extentBYTES NUMBER Size of the extent in bytesBLOCKS NUMBER Size of the extent in Oracle blocksRELATIVE_FNO NUMBER Relative file number of the first extent block [SQL] SELECT 'alter database datafile' | chr (39) | file _ Name | chr (39) | 'resize' | ceil (hwmsize * 1.2) |'m; 'FROM (SELECT. file_id,. file_name,. filesize, B. freesize, (. filesize-b.freesize) usedsize, c. hwmsize, c. hwmsize-(. filesize-b.freesize) unsedsize_belowhwm,. filesize-c. hwmsize canshrinksize FROM (select file_id, file_name, ROUND (bytes/1024/1024) filesize FROM dba_data_files) a, (select file_id, ROUND (SUM (dfs. bytes)/1024/1024) frees Ize FROM dba_free_space dfs group BY file_id) B, (select file_id, ROUND (MAX (block_id) * 8/1024) HWMsize FROM dba_extents group BY file_id) c where. file_id = B. file_id and. file_id = c. file_id order BY unsedsize_belowhwm DESC) [SQL] alter database datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ USERS_NEW 'resize 5755 M; alter database datafile' F: \ ORACLE \ ORADATA \ PURPLE \ system01.dbf' resize 4574 M; alter databa Se datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ INDEX_NEW 'resize 825 M; alter database datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ users01.dbf' resize 17980 M; alter database datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ sysaux01.dbf' resize 670 M; alter database datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ example01.dbf' resize 90 M; alter database datafile 'f: \ ORACLE \ ORADATA \ PURPLE \ undotbs01.dbf' resize 72 M; a total of 7 GB space is released.

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.