Copying table structure not data : Copy Table « Table « Oracle PL / SQL






Copying table structure not data

   

SQL>
SQL> CREATE TABLE myTable (
  2     Name    VARCHAR(50) PRIMARY KEY NOT NULL,
  3     PhoneNo VARCHAR(15) DEFAULT 'Unknown Phone',
  4     SSN     VARCHAR(15) NOT NULL,
  5     CHECK (SSN LIKE '[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'));

Table created.

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

Table created.

SQL>
SQL> drop table myTable;

Table dropped.

SQL> drop table My_myTables;

Table dropped.

   
    
    
  








Related examples in the same category

1.Use copy command to create new table
2.Create a copy table and insert value to it
3.Copying selected columns from another table
4.Copying selected columns from multiple tables
5.CREATE Table from another table with consitions
6.Duplicate some or all of the data in one table under a different table name
7.Create a copy table with primary key setting
8.Copying table
9.Create table as select * from another
10.Create a copy table from all_objects
11.Creating from Another Table
12.The table is created with no rows if the query returned no rows.