DB2 gives us an option to copy the structure of an existing table to a new table. To copy the attributes and column of table TAB1 to a new table TAB2 we can use the following command−
CREATE TABLE DBSET1.TAB2 LIKE DBSET1.TAB1
The CREATE TABLE reserved words are followed by table name. The table name needs to be qualified by a database in which it will reside. In this case this new table is TAB2 and its database is DBSET1.
The LIKE parameter is used after that followed by the name of the original table qualified by its database i.e. DBSET1.TAB1
The important point to note here is, primary and foreign keys are not inherited automatically and we have to define them using the ALTER table command on the new table.