Creating a table using LIKE

 

You can create a table that looks like another table. That is, you can create a table that includes all of the column definitions from an existing table.

The following definitions are copied:

If the LIKE clause immediately follows the table name and is not enclosed in parentheses, the following attributes are also included:

If the specified table or view contains an identity column, specify INCLUDING IDENTITY on the CREATE TABLE statement if you want the identity column to exist in the new table. The default behavior for CREATE TABLE is EXCLUDING IDENTITY. If the specified table or view is a non-SQL created physical file or logical file, any non-SQL attributes are removed.

Create a table EMPLOYEE2 that includes all of the columns in EMPLOYEE:

CREATE TABLE EMPLOYEE2 LIKE EMPLOYEE

 

Parent topic:

Data definition language

 

Related reference


CREATE TABLE