TABLESPACE (tablespace) type
①PERMANENT permanent table space
②UNDO undo tablespace
③TEMPORARY temporary table space
Management:
Focusing on management and management area of the segment is determined at the time of the establishment of table space.
There AUTO segment management and MANUAL are two kinds of area management with local administrative and dictionary management (deprecated) two kinds.
SQL> select tablespace_name,contents ,extent_management,segment_space_management from dba_tablespaces;
TABLESPACE_NAME CONTENTS EXTENT_MAN SEGMEN
------------------------------ --------- ---------- ------
The PERMANENT DICTIONARY the SYSTEM MANUAL ## manual
SYSAUX PERMANENT LOCAL AUTO
TEMP TEMPORARY LOCAL MANUAL
The PERMANENT the LOCAL USERS AUTO automatic ##
EXAMPLE PERMANENT LOCAL AUTO
UNDO_TBS01 UNDO LOCAL MANUAL
TMP01 TEMPORARY LOCAL MANUAL
TEST PERMANENT DICTIONARY MANUAL
Basic Operations
1) the establishment of table space
SQL> create tablespace a datafile '/u01/oradata/prod/a01.dbf' size 10m;
Dbms_metadata.get_ddl use oracle package provides default values to see what gave that?
SQL> set serverout on;
SQL>declare
aa varchar2 (2000);
begin
select dbms_metadata.get_ddl('TABLESPACE','B') into aa FROM dual;
dbms_output.put_line(aa);
end;
/
result:
CREATE TABLESPACE "A" DATAFILE
'/u01/oradata/prod/a01.dbf' SIZE 10485760
LOGGING ONLINE PERMANENT BLOCKSIZE
8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
SEGMENT SPACE MANAGEMENT AUTO
PL / SQL procedure successfully completed.
Watch the last line, two important information: (1) local administrative area and automatically allocate space segment (2) automatic management.
----------------------------------
SQL>create tablespace b datafile '/u01/oradata/prod/b01.dbf' size 10m
extent management local uniform size 128k
segment space management manual
Ibid., See Oracle packages transferred dbms_metadata.get_ddl the statement ddl operations are:
CREATE TABLESPACE "B" DATAFILE
'/u01/oradata/prod/a01.dbf' SIZE 10485760
LOGGING ONLINE PERMANENT BLOCKSIZE
8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 131072 SEGMENT SPACE MANAGEMENT MANUAL
The last line is: local area management and uniform distribution 128K, manual segment management. If you use the default description in the construction of the table, the table will be subject to the definitions of its table spaces
Delete table space
Delete and offline table space
The SQL> drop TABLESPACE Including Test Contents and Datafiles; ## Contents and file comprises control data dictionary information, datafiles physical data files.
Under OPEN database table space is not deleted
①system ②active undo tablespace ③default temporary tablespace ④default tablespace
Under OPEN database table space is not offine
①system ②active undo tablespace ③default temporary tablespace
View table space size
SQL> select TABLESPACE_NAME,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
Check the size of the table space free
SQL> select TABLESPACE_NAME,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
TABLESPACE_NAME SUM(BYTES)/1024/1024
------------------------------ --------------------
UNDOTBS1 98.4375
SYSAUX 14.625
USERS 48.1875
SYSTEM 1.875
EXAMPLE 31.25
View table space (data files) if automatic extension
SQL> col file_name for a40;
SQL> select file_name,tablespace_name,bytes/1024/1024 mb,autoextensible from dba_data_files;
Modify the table space is automatically extended
SQL>alter database datafile '/u01/app/oracle/oradata/orcl/users_d01.dbf' autoextend on;
Are you sure to have been successfully modified
SQLl> SELECT tablespace_name, file_name, autoextensible from dba_data_files WHERE tablespace_name = 'the USERS';
TABLESPACE_NAME FILE_NAME the AUT
----------------- -------- --- ---------------------------------
SEC_D / u01 / App / the Oracle / ORA the Data / orcl / users_d01 .dbf YES
Summary of the changes statement syntax
open the automatic extension syntax:
ALTER Database datafile 'corresponding data file path information' autoextend on;
off automatic extension syntax:
ALTER Database datafile 'corresponding data file path information' autoextend off;
---------------------------------------------------------------------------------
1. Data files automatically extended benefits
1) does not occur because there is no room left to take advantage of the data can not be written
2) minimize human maintenance
3) can be used significant level is not very large databases, such as databases, test
2 the data file is automatically extended drawbacks
1) If allowed to expand, the amount of data ever larger process will lead to a large anomalous data file
2) no management database is very dangerous
The establishment of large files (bigfile) table space
①small file, in a table space can create multiple data files (default)
②bigfile: only create a table space in a data file (must be 8k the block, up to 32T), to simplify the data file management .
SQL> create bigfile tablespace big_tbs datafile '/u01/oradata/prod/bigtbs01.dbf' size 100m;
Trying to increase a data file in this table space will complain
SQL> alter tablespace big_tbs add datafile '/u01/oradata/prod/bigtbs02.dbf' size 100 m;
报错:ORA-32771: cannot add file to bigfile tablespace
View large table space:
SQL> select name,bigfile from v$tablespace;