Create Normal Table and Global Temporary Table in Oracle

We can create two types of Table in Oracle.

1) Normal Table (CREATE TABLE Command)

2) Global Temporary Table (CREATE GLOBAL TEMPORARY TABLE Command)

create table

How to create a Normal Table in Oracle?

The create table command allows you to create normal table in Oracle. The syntax of CREATE TABLE command is as follows:

CREATE TABLE table-name
( 
  Column-1 data-type null/not null,
  Column-2 data-type null/not null,
  ...
);

It is mandatory to have a data type of a column. You can define a column either as NULL or NOT NULL and if this value is left blank, the oracle database assumes it NULL by default.
You can see the below example where two columns are defined as NOT NULL and two without NULL, it means the column can have NULL values by default.

Example:

CREATE TABLE TB_EMPLOYEE
     ( EMP_ID NUMBER(10) NOT NULL,
       EMP_NAME VARCHAR2(50) NOT NULL,
       EMP_CITY VARCHAR2(50),
       EMP_STATE VARCHAR2(50)
     );

How to create Global Temporary Table in Oracle?

You can create and manage Global temporary tables within SQL sessions. You can create Global temporary table using following syntax:

CREATE GLOBAL TEMPORARY TABLE table-name
( 
  Column-1 data-type null/not null,
  Column-2 data-type null/not null,
  ...
);

Example:

Following example would create a Global Temporary table called TB_EMPLOYEE in Oracle.

CREATE GLOBAL TEMPORARY TABLE TB_EMPLOYEE
     ( EMP_ID NUMBER(10) NOT NULL,
       EMP_NAME VARCHAR2(50) NOT NULL,
       EMP_CITY VARCHAR2(50),
       EMP_STATE VARCHAR2(50)
     );

I hope you understood how to create normal table and global temporary table in Oracle.

1 thought on “Create Normal Table and Global Temporary Table in Oracle”

  1. Keshab

    What is the difference between Global Temporary table and Normal temporary table in Oracle ? Could some one say there difference in Vertica DB as well?

Leave a Comment

Your email address will not be published. Required fields are marked *

shares
Scroll to Top