Using Global Temporary tables in Oracle

This article is written about how to use the Oracle GLOBAL TEMPORARY TABLES with syntax and examples.

Description

GLOBAL TEMPORARY TABLES in Oracle are tables that are created distinct within the Oracle sessions.

Syntax

The syntax for Oracle CREATE GLOBAL TEMPORARY TABLE is:

CREATE GLOBAL TEMPORARY TABLE table_name
( column1 datatype [ NULL | NOT NULL ],
  column2 datatype [ NULL | NOT NULL ],
  ...
  column_n datatype [ NULL | NOT NULL ]
);

Parameters or Arguments

table_name The identify of the world temporary desk that you wish to create. column1, column2, … column_n The columns that you want to create in the international temporary table. Each column should have a datatype. The column need to both be described as NULL or NOT NULL and if this fee is left blank, the database assumes NULL as the default.

Example

Let’s appear at an Oracle CREATE GLOBAL TEMPORARY TABLE example:

CREATE GLOBAL TEMPORARY TABLE suppliers
( supplier_id numeric(10) NOT NULL,
  supplier_name varchar2(50) NOT NULL,
  contact_name varchar2(50)
);

This instance would create a GLOBAL TEMPORARY TABLE known as suppliers.