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)
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.
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, ... );
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.
Get Free Blogging Tips & Technology updates in your Email !!!
Latest posts by Anil Verma (see all)
- BlueHost Affiliate Program – Earn $65 Per Referral - August 2, 2015
- WP Engine Affiliate Program – Earn $200 Per Referral - August 1, 2015
- How to fill out BlueHost Affiliate Tax form for Non-US Residents - June 20, 2015