Using create table tab2 as select * from tab1;
, I am able to copy the data but not the primary key constraint :
SQL> desc tab1;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(20)
SQL> select * from tab1;
ID NAME
---------- --------------------
1 A
SQL> create table tab2 as select * from tab1;
Table created.
SQL> desc tab2;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
NAME VARCHAR2(20)
SQL> select * from tab2;
ID NAME
---------- --------------------
1 A
SQL>
How can I copy the table with all its constraints as well?