Sie sind auf Seite 1von 4

Tablespaces physically group schema objects for administration convenience.

They bridge physical structures, such as datafiles or extents, and logical structures, such as tables and indexes. Tablespaces can store zero or more segments. Segments are schema objects that require storage outside the data dictionary. Tables and indexes are examples of segments. Constraints and sequences are examples of schema objects that do not store data outside the data dictionary and are therefore not segments. A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace is not visible in the file system of the operating system on which the database resides. A tablespace, consists of at least one datafile which, in turn, are physically located in the file system of the server. Other logical objects like tables,indexes, materialized views are created in the tablespace Tablespaces helps in logical grouping of data Every user in the database is associated with a default tablespace and all the tables and indexes for the user will be created in the default tablespace unless specified otherwise The tablespace builds the bridge between the Oracle database and the filesystem in which the table's or indexs data is stored.

Details about the tablespace can be obtained from the following data dictionary views 1. dba_tablespaces dba_data_files 2. dba_free_spaces 3. Dba_tablespaces , gives the details of the existing tablespaces 4. Dba_data_files, gives the details of datafiles belonging to each tablespace 5. Dba_free_space , gives the details of the freespace available in each tablespace SQL> CREATE TABLESPACE ts2 DATAFILE '/oradata/ts2_01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL AUTOALLOCATE; SQL> CREATE TABLESPACE ts3 DATAFILE '/oradata/ts3_01.dbf SIZE 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K; -To get total size SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name order by 1;

The DBA_DATA_FILES views contain information on datafiles. This information includes the tablespace name, filename, file size, and autoextend settings. SQL> SELECT tablespace_name, file_name FROM dba_data_files; - to get allocated size SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_segments group by tablespace_name order by 1; -To get free space SQL> select tablespace_name,sum(bytes)/1024/102 from dba_free_space group by tablespace_nameorder by 1; Mandatory Tablespaces: System , sysaux and temporary tablespaces are called mandatory tablespaces These tablespaces are created automatically when a new database is created The database cannot be opened if any of these tablespaces are missing/inaccessable

Types of Tablespaces: 1. SYSTEM Tablespaces Every Oracle database contains a tablespace named SYSTEM, which Oracle creates automatically when the database is created. The SYSTEM tablespace is always online when the database is open. The system tablespace stores the data dictionary. Data dictionary contains metadata about a database Metadata is known as information about information, so data dictionary contains all information about the database.

2. SYSAUX Tablespaces The SYSAUX tablespace is an auxiliary tablespace to the SYSTEM tablespace. It is new with Oracle 10g. It is used to store database components that were stored in the system tablespace in prior releases of the database. Many database components use the SYSAUX tablespace as their default location to store data.

Therefore, the SYSAUX tablespace is always created during database creation or database upgrade. The SYSAUX tablespace provides a centralized location for database metadata that does not reside in the SYSTEM tablespace. It reduces the number of tablespaces created by default, both in the seed database and in userdefined databases.

3.UNDO Tablespaces Undo tablespaces are special tablespaces used solely for storing undo information. You cannot create any other segment types (for example, tables or indexes) in undo tablespaces. In automatic undo management mode, each Oracle instance is assigned one (and only one) undo tablespace. Undo data is managed within an undo tablespace using undo segments that are automatically created and maintained by Oracle. To create a undo tablespace: CREATE UNDO TABLESPACE undotbs_02 DATAFILE '/dbs/undo01.dbf' SIZE 20M; To add a datafile to a undo table space: ALTER TABLESPACE undotbs_01 ADD DATAFILE'/dbs/undo01.dbf' size 50M; To drop a undo tablespace: DROP TABLESPACE undotbs_01 INCLUDING CONTENTS AND DATAFILES ; 4. USER Tablespaces In the best practice , user objects can be created in the user tablespaces. When a database is created by dbca , a tablespace will be created and assigned as user tablespaces Database default User tablespace is assigned as the default tablespace for the user, if the default tablespace clause is omitted while user creation The default permanent tablespace for the database can obtained by the following sql

Sql>selectproperty_valuefromdatabase_propertieswhere property_name=DEFAULT_PERMANENT_TABLESPACE;

5. TEMPORARY Tablespaces

Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory space will be allocated in a temporary tablespace for doing the sort operation. The DBA should assign a temporary tablespace to each user in the database to prevent them from allocating sort space in the SYSTEM tablespace.

The default temporary tablespace for the database can obtained by the following sql sql>selectproperty_valuefromdatabase_properties whereproperty_name=DEFAULT_TEMP_TABLESPACE;

Das könnte Ihnen auch gefallen