PL/SQL Create Table

Oracle PL/SQL Create Table

Create Table Example:

create table OFFERS(
ID	NUMBER(12)	not null,
CUSTOMER_ID	NUMBER(12)	not null,
PRODUCT_ID	NUMBER(4)	not null,
AMOUNT	NUMBER(12,2)	not null,
CREATE_DATE	DATE	not null,
START_DATE	DATE	not null,
END_DATE	DATE	not null,
DETAILS	VARCHAR2(1000),	
USER_CODE	NUMBER(4)	not null,
UNIT	NUMBER(2)	not null,
CONSTRAINT PK_ID PRIMARY KEY (ID)
) ;

Copying all columns from another table

Create table new_offers
As ( Select * 
From offers o
Where o.amount > 6000 );

Copying selected columns from another table

Create table new_offers
As ( Select o.id, o.customer_id, o.product_id, o.amount
From offers o
Where o.amount > 6000 );

Copying selected columns from multiple tables

Create table sales
As ( Select o.id, o.customer_id, o.product_id, o.amount, c.cip, c.name
From offers o, customers c
Where o.customer_id = c.customer_id
And o.amount > 6000 );