Wednesday, August 9, 2023

Create tablespace In Oracle database

Important Facts in Oracle:- physical structures:- data files, redo log files, archive log files, control files, parameter files, etc. logical structures:- tablespaces, extents, segments, etc. if you wish to see some visible content in physical files like data files, etc. $ strings system01.dbf Schemas ---> Take it as 'Container of all Objects created by a User in Database' Objects:- tables, procedures, functions, views, packages, etc. packages:- optimized collection of objects or say ease to access objects SYSTEM tablespace: This tablespace is created when the database is created and contains the data dictionary, which stores information about the database objects, such as tables, indexes, and constraints. The SYSTEM tablespace is used by the database itself, and it should not be used for storing user data. SYSAUX tablespace: This tablespace is used to store system-related metadata and noncritical system data. It includes components such as the Automatic Workload Repository (AWR), Oracle Text, and Oracle Spatial. This tablespace is created automatically when the database is created, and it is recommended to leave the SYSAUX tablespace as it is. TEMP tablespace: This tablespace is used to store temporary data that is generated during query execution, sorting, and joining. The TEMP tablespace is used by the database for performing operations that require large amounts of temporary storage. It is recommended to create a separate TEMP tablespace for each Oracle instance to improve performance. UNDO tablespace: This tablespace is used to store undo information, which is used to roll back changes made to the database. The UNDO tablespace is used by the database to support transactions and provides a way to recover the database to a previous state. It is recommended to create a separate UNDO tablespace for each Oracle instance to improve performance. USERS tablespace: This tablespace is used to store user data such as tables, indexes, and other objects. The USERS tablespace is created by default, and it is recommended to create additional tablespaces for storing user data to manage data growth and improve performance. INDEX tablespace: This tablespace is used to store indexes that are created on user tables. It is recommended to create separate INDEX tablespaces to improve performance by separating index data from user data. LOB tablespace: This tablespace is used to store Large Object (LOB) data such as images, videos, and other large files. It is recommended to create a separate LOB tablespace for each table that contains LOB data to improve performance and manage data growth.


 --- To create temporary tablespace 

CREATE TEMPORARY TABLESPACE temp_ts

TEMPFILE '/path/to/tempfile/temp01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


--- To create undo tablespace

CREATE undo TABLESPACE undo_ts

datafile '/path/to/undofile/undo01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


--- To create users tablespace

CREATE  TABLESPACE users_ts

datafile '/path/to/usersfile/users01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


--- To create system tablespace

CREATE  TABLESPACE system_ts

datafile '/path/to/systemfile/system01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


--- To create sysaux tablespace

CREATE  TABLESPACE sysaux_ts

datafile '/path/to/sysauxfile/sysaux01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


--- To create LOB tablespace (stores large objects like BLOBs, CLOB, etc)

CREATE  TABLESPACE lob_ts

TEMPFILE '/path/to/lobfile/lob01.dbf' 

SIZE 100M REUSE 

AUTOEXTEND ON NEXT 10M 

MAXSIZE UNLIMITED;


No comments:

Post a Comment

Enable OpenSSH on Windows 11

Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...