Basic operation oracle-- tablespace

- look-up table space usage situation (including temporary table space) 
the SELECT d.tablespace_name "the Name", d.status "the Status", 
       the TO_CHAR (of the NVL (a.BYTES /  1024  /  1024 , 0 ), ' 99,999,990.90 ' ) "Size (M) ", 
          the TO_CHAR (of the NVL (a.BYTES - of the NVL (f.BYTES, 0 ), 0 ) /  1024  /  1024 ,
                    ' 99,999,999.99 ' 
                  ) the USE , 
       the TO_CHAR (of the NVL ((a.BYTES - of the NVL (f.BYTES, 0 )) / a.BYTES * 100, 0),
                '990.00'
               ) "Used %"
  FROM SYS.dba_tablespaces d,
       (SELECT   tablespace_name, SUM (BYTES) BYTES
            FROM dba_data_files
        GROUP BY tablespace_name) a,
       (SELECT   tablespace_name, SUM (BYTES) BYTES
            FROM dba_free_space
        GROUP BY tablespace_name) f
 WHERE d.tablespace_name = a.tablespace_name(+)
   AND d.tablespace_name = f.tablespace_name(+)
   AND NOT (d.extent_management LIKE 'LOCAL' AND d.CONTENTS LIKE 'TEMPORARY')
UNION ALL
SELECT d.tablespace_name "Name", d.status "Status", 
       TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.90') "Size (M)",
          TO_CHAR (NVL (t.BYTES, 0) / 1024 / 1024, '99999999.99') USE,
       TO_CHAR (NVL (t.BYTES / a.BYTES * 100, 0), '990.00') "Used %"
  FROM SYS.dba_tablespaces d,
       (SELECT   tablespace_name, SUM (BYTES) BYTES
            FROM dba_temp_files
        GROUP BY tablespace_name) a,
       (SELECT   tablespace_name, SUM (bytes_cached) BYTES
            FROM v$temp_extent_pool
        GROUP BY tablespace_name) t
 WHERE d.tablespace_name = a.tablespace_name(+)
   AND d.tablespace_name = t.tablespace_name(+)
   AND d.extent_management LIKE 'LOCAL'
   AND d.CONTENTS LIKE 'TEMPORARY';

1. 查询表空间剩余字节大小
SELECT TABLESPACE_NAME, SUM(BYTES)/1024/1024 The AS "the FREE the SPACE (M)"
   the FROM DBA_FREE_SPACE
  the WHERE TABLESPACE_NAME =  ' & tablespace_name ' 
 the GROUP  BY TABLESPACE_NAME; 
Note: If the temporary table space, query DBA_TEMP_FREE_SPACE 
the SELECT TABLESPACE_NAME, FREE_SPACE / 1024 / 1024  the AS "the FREE the SPACE (M)"
   the FROM DBA_TEMP_FREE_SPACE
  the WHERE tABLESPACE_NAME =  ' & tablespace_name ' ; 

2 . All spatial lookup table data file paths
 the SELECT tABLESPACE_NAME, FILE_ID ,FILE_NAME , BYTES / 1024 / 1024  the AS "BYTES (M)"
   the FROM the DBA_DATA_FILES
  the WHERE TABLESPACE_NAME =  ' & tablespace_name ' ; 
Note: If the temporary table space, query DBA_TEMP_FILES 
the SELECT TABLESPACE_NAME, FILE_ID , FILE_NAME , BYTES / 1024 / 1024  the AS " the SPACE ( M) "
   the FROM DBA_TEMP_FILES
  the WHERE tABLESPACE_NAME =  ' & tablespace_name ' ; 

. 3 . a tablespace is insufficient to increase the data files
The ALTER TABLESPACE & tablespace_name the ADD DATAFILE ' & datafile_name ' SIZE 2G; 
Note: If you want to expansion temporary table space, use the following statement 
the ALTER TABLESPACE & tablespace_name the ADD TEMPFILE ' & datafile_name ' SIZE 2G; 

. 4 View size and data file path temporary table space.
 the SELECT TABLESPACE_NAME, FILE_ID , FILE_NAME , BYTES / 1024 / 1024  the AS " the SPACE (M)"
   the FROM DBA_TEMP_FILES
  the WHERE TABLESPACE_NAME = ' The TEMP ' ; 
or 
select name, bytes / 1024 / 1024  AS "size (M)" from v $ tempfile the Order  by bytes; 

5 rebuild and modify the default temporary table space way:
 - query the current database default temporary table space 
select  *  from DATABASE_PROPERTIES the WHERE property_name = ' DEFAULT_TEMP_TABLESPACE ' ;
 - create a new temporary table space for 
the create  the temporary tABLESPACE temp02 tempfile ' E: \ the Oracle \ oradata \ LIMS \ TEMP02.DBF ' size 1024M AUTOEXTENDON ;
 - modify the default table space for just created temporary table space for 
the ALTER  Database  default  the Temporary TABLESPACE temp02;
 - view the user of temporary table space with 
the SELECT USERNAME, temporary_tablespace the FROM DBA_USERS;
 - delete the original temporary table space 
drop TABLESPACE the TEMP Contents Including and the Datafiles;
 - see all table space to confirm whether the temporary table space is deleted 
the SELECT tablespace_name from dba_tablespaces; 

 

--------------------- Disclaimer: This article is CSDN blogger "okhymok 'original article, follow the CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement. Original link: https: //blog.csdn.net/okhymok/article/details/83538970
[--------------------- Bǎnquán shēngmíng: Benwin Karen CSDN Bo zhǔ okhymok'de yuánchuàng wénzhāng 4.0 zūnxún CC BY-SA bǎnquán xiéyì, zhuǎnzài qǐng Fu Shan yuánwén chuchi liànjiē Ji Ben shēngmíng. Yuánwén liànjiē: http: //Blog.Csdn.Net/okhymok/article/details/83538970]
---------------------
Copyright statement: This article is the original article of CSDN blogger "okhymok", following the CC 4.0 by-sa copyright agreement, please reprint the original source link and this statement.
Original link: https://blog.csdn.net/okhymok/article/details/83538970

Guess you like

Origin www.cnblogs.com/kingle-study/p/11353156.html