Help in copying table structure to another table with constraints in Oracle

hi,

i need to copy one table with data into another table,

right now am using

create table table1 as select * from table2

i want the constraints of table1 to be copied to table2 also , can anyone give me some solution to copy the constraints also, now am using oracle 10.2.0.3.0 version.

thanks,
senthil

You can use the package dbms_metadata.get_ddl to get the create statement that includes constraint definitions.

set long 1000 lin 1000
select DBMS_METADATA.get_ddl ('TABLE','TABLE1') FROM DUAL;

Once you have the create statement, just change all constraint names (should be unique) and run it.