top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

SQL: LOCAL TEMPORARY TABLES

0 votes
280 views

This SQL tutorial explains how to create SQL LOCAL TEMPORARY tables with syntax and examples.

Description

SQL LOCAL TEMPORARY TABLES are distinct within modules and embedded SQL programs within SQL sessions.

Syntax

The syntax for DECLARE LOCAL TEMPORARY TABLE in SQL is:

DECLARE LOCAL TEMPORARY TABLE table_name
( column1 datatype [ NULL | NOT NULL ],
  column2 datatype [ NULL | NOT NULL ],
  ...
);

Parameters or Arguments

table_name

The name of the local temporary table that you wish to create.

column1, column2

The columns that you wish to create in the local temporary table. Each column must have a datatype. The column should either be defined as NULL or NOT NULL and if this value is left blank, the database assumes NULL as the default.

Example

Let's look at a SQL DECLARE LOCAL TEMPORARY TABLE example:

DECLARE LOCAL TEMPORARY TABLE suppliers_temp
( supplier_id int NOT NULL,
  supplier_name char(50) NOT NULL,
  contact_name char(50)
);

This example would create a LOCAL TEMPORARY TABLE called suppliers_temp.

posted Feb 24, 2017 by Shivaranjini

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

his SQL tutorial explains how to create SQL GLOBAL TEMORARY tables with syntax and examples.

Description

SQL GLOBAL TEMPORARY TABLES are tables that are created distinct within SQL sessions.

Syntax

The syntax for CREATE GLOBAL TEMPORARY TABLE in SQL is:

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

Parameters or Arguments

table_name

The name of the global temporary table that you wish to create.

column1, column2

The columns that you wish to create in the global temporary table. Each column must have a datatype. The column should either be defined as NULL or NOT NULL and if this value is left blank, the database assumes NULL as the default.

Example

Let's look at a SQL CREATE GLOBAL TEMPORARY TABLE example:

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

This example would create a GLOBAL TEMPORARY TABLE called suppliers_temp.

READ MORE
...