Creating Table from another Table : Oracle

Copy Table to a new table with some condition
______________________________________________

SQL> CREATE TABLE newTable AS (SELECT * FROM emp WHERE sal > 2000);

CREATE TABLE testholder AS (SELECT * FROM histholder WHERE cardholder=325073128);

Copying table structure not data
_______________________________

SQL> CREATE TABLE My_myTables AS SELECT * FROM myTable WHERE 1=0;

CREATE TABLE testholder AS SELECT * FROM histholder WHERE 1=0;

### note this will not copy or create indexes, you have to create indexes explicitly.

The table is created with no rows if the query returned no rows.

________________________________________________________________

CREATE TABLE Y AS SELECT * FROM X WHERE 1 = 2;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s