Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

Oracle CREATE TABLESPACE operator

19 August 2020

Oracle CREATE TABLESPACE operator

The CREATE TABLESPACE operator is used to allocate space in the Oracle database where schema objects are stored.

The CREATE TABLESPACE operator can be used to create three types of tabular spaces

  • Permanent Tablespace
  • Temporary Tablespace
  • Undo Tablespace

We will consider all 3 types of tabular spaces.

1. Permanent Tablespace

A persistent table space contains permanent schema objects, which are stored in data files.

The CREATE TABLESPACE instruction syntax for creating a permanent table space:

CREATE
[ SMALLFILE | BIGFILE ]
TABLESPACE tablespace_name
{ DATAFILE }{ [ 'filename' | 'ASM_filename' ]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
[ AUTOEXTEND
{ OFF
| ON [ NEXT integer [ K | M | G | T | P | E ] ]
[ MAXSIZE { UNLIMITED | } [ K | M | G | T | P | E ] } ]
}
]
| [ 'filename | ASM_filename']
| ('filename | ASM_filename')
[, 'filename | ASM_filename' ] ).
]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
}
{ MINIMUM EXTENT integer [ K | M | G | T | P | E ]
| BLOCKSIZE integer [ K ]
| { LOGGING | NOLOGGING }
| FORCE LOGGING
| DEFAULT [ {COMP | NOCOMPRESS } ]
storage_clause
| { ONLINE | OFFLINE }
|
{LOCAL
[ AUTOALLOCATE
| UNIFORM
[ SIZE integer [ K | M | G | T | P | E ] ]
]
| DICTIONARY
}
| SPACE MANAGEMENT { AUTO | MANUAL }
| FLASHBACK { ON | OFF }
[ MINIMUM EXTENT integer [ K | M | G | T | P | E ]
| BLOCKSIZE integer [ K ]
| { LOGGING | NOLOGGING }
| FORCE LOGGING
| DEFAULT [ {COMP | NOCOMPRESS } ]
storage_clause
| { ONLINE | OFFLINE }
|
{LOCAL
[ AUTOALLOCATE | UNIFORM [ SIZE integer [ K | M | G | T | P | E ] ] ]
| DICTIONARY
}
| SPACE MANAGEMENT { AUTO | MANUAL }
| FLASHBACK { ON | OFF }
]
}

  • SMALLFILE is a table space containing 1022 data files or temporary files (each file can contain up to 4 million blocks). This is the most common size for creating a tabular space.
  • BIGFILE is a table space containing only one data file or temporary file (each file can contain up to 4 million blocks).

TIP. If you omit SMALLFILE or BIGFILE, the Oracle database will use the default table space type.

  • tablespace_name is the name of the table space you are creating.
  • storage_clause – the syntax for storage_clause:

STORAGE 
({ INITIAL integer [ K | M | G | T | P | E ]
| NEXT integer [ K | M | G | T | P | E ]
| MINEXTENTS integer
| MAXEXTENTS { integer | UNLIMITED }
| PCTINCREASE integer
| FREELISTS integer
| FREELIST GROUPS integer
| OPTIMAL [ K | M | G | T | P | E ] | NULL ]
| BUFFER_POOL { KEEP | RECYCLE | DEFAULT }
}
[ INITIAL integer [ K | M | G | T | P | E ]
| NEXT integer [ K | M | G | T | P | E ]
| MINEXTENTS integer
| MAXEXTENTS { integer | UNLIMITED }
| PCTINCREASE integer
| FREELISTS integer
| FREELIST GROUPS integer
| OPTIMAL [ K | M | G | T | P | E ] | NULL ]
| BUFFER_POOL { KEEP | RECYCLE | DEFAULT }
]
)

Example PERMANENT TABLESPACE

Below is the CREATE TABLESPACE operator, which creates a simple permanent table space:

CREATE TABLESPACE tbs_perm_01
DATAFILE 'tbs_perm_01.dat' 
SIZE 20M
ONLINE;

This CREATE TABLESPACE operator creates a permanent table space tbs_perm_01 that has one data file tbs_perm_01.dat.

Below is a CREATE TABLESPACE statement that creates a persistent table space that will expand when more space is needed:

CREATE TABLESPACE tbs_perm_02
DATAFILE 'tbs_perm_02.dat' 
SIZE 10M
REUSE
AUTOEXTEND ON NEXT 10M MAXSIZE 200M;

This CREATE TABLESPACE operator creates a permanent table space tbs_perm_02 with one data file tbs_perm_02.dat. When more space is needed, 10M extents will be automatically added until 200MB is reached.

Below is the CREATE TABLESPACE operator, which creates a permanent BIGFILE table space that will expand when more space is needed:

CREATE BIGFILE TABLESPACE tbs_perm_03
DATAFILE 'tbs_perm_03.dat'
SIZE 10M
AUTOEXTEND ON;

This CREATE TABLESPACE statement creates a permanent BIGFILE table space named tbs_perm_03 that has one data file named tbs_perm_03.dat.

2. Temporary Tablespace

The temporary tabular space contains schema objects that are stored in temporary files that exist during the session.

Syntax of the CREATE TABLESPACE operator when creating temporary tabular space:

CREATE
[ SMALLFILE | BIGFILE ]
TEMPORARY TABLESPACE tablespace_name
[ TEMPFILE { [ 'filename' | 'ASM_filename' ]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
[ AUTOEXTEND
{ OFF
| ON [ NEXT integer [ K | M | G | T | P | E ] ]
[ MAXSIZE { UNLIMITED | ] ] [ K | M | G | T | P | E ] ] ?
}
]
| [ 'filename | ASM_filename']
| ('filename | ASM_filename')
[, 'filename | ASM_filename' ] ).
]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
}
[ TABLESPACE GROUP { tablespace_group_name | " } ]
[ EXTENT MANAGEMENT
{LOCAL
[ AUTOALLOCATE | UNIFORM [ SIZE integer [ K | M | G | T | P | E ] ] ?]
| DICTIONARY
} ]

  • SMALLFILE is a table space containing 1022 data files or temporary files (each file can contain up to 4 million blocks). This is the most common size for creating a tabular space.
  • BIGFILE is a table space containing only one data file or temporary file (each file can contain up to 4 million blocks).

TIP. If you omit SMALLFILE or BIGFILE, the Oracle database will use the default table space type.

  • tablespace_name is the name of the table space you are creating.

Example TEMPORARY TABLESPACE

Below is the CREATE TABLESPACE operator that creates a temporary tabular space:

CREATE TEMPORARY TABLESPACE tbs_temp_01
TEMPFILE 'tbs_temp_01.dbf'
SIZE 5M
AUTOEXTEND ON;

This CREATE TABLESPACE operator creates a temporary table space tbs_temp_01 with one temporary file tbs_temp_01.dbf.

3. UNDO TABLESPACE

For undo tabular undo space, if the Oracle database runs in automatic undo mode.
The undo table space is created to manage undo data if the Oracle database runs in automatic undo management mode.

Syntax of CREATE TABLESPACE operator when creating Undo table space:

CREATE
[ SMALLFILE | BIGFILE ]
UNDO TABLESPACE tablespace_name
[ DATAFILE { [ 'filename' | 'ASM_filename' ]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
[ AUTOEXTEND
{ OFF
| ON [ NEXT integer [ K | M | G | T | P | E ] ]
[ MAXSIZE { UNLIMITED | ] ] [ K | M | G | T | P | E ] ] ?
}
]
| [ 'filename | ASM_filename']
| ('filename | ASM_filename')
[, 'filename | ASM_filename' ] ).
]
[ SIZE integer [ K | M | G | T | P | E ] ]
[ REUSE ]
}
[ EXTENT MANAGEMENT
{LOCAL
[ AUTOALLOCATE | UNIFORM [ SIZE integer [ K | M | G | T | P | E ] ] ?]
| DICTIONARY
} ]
[ RETENTION { GUARANTEE | NOGUARANTEE } ]

  • SMALLFILE is a table space containing 1022 data files or temporary files (each file can contain up to 4 million blocks). This is the most common size for creating a table space.
  • BIGFILE is a table space containing only one data file or temporary file (each file can contain up to 4 million blocks).

TIP. If you omit SMALLFILE or BIGFILE, the Oracle database will use the default table space type.

  • tablespace_name is the name of the table space you are creating.

Example – UNDO TABLESPACE

Below is the CREATE TABLESPACE operator, which creates Undo table space:

CREATE UNDO TABLESPACE tbs_undo_01
DATAFILE 'tbs_undo_01.f'
SIZE 5M
AUTOEXTEND ON
RETENTION GUARANTEE;

This CREATE TABLESPACE operator creates a 5MB tbs_undo_01 table space and has one tbs_undo_01.f data file.

Oracle Database tutorial: How to create Tablespace using SQL

 
Tags: , , , , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...