How to copy table structure

Applies To

OS:
Database:
Any
Any

Say you want to copy the structure of the table without copying data. Then, use this simple SQL statement.
SELECT *
INTO my_new_table
FROM my_old_table
WHERE 1=2
This code copies the structure of table my_old_table and creates a new table called my_new_table with identical structure.

Note, that the INTO clause is what is known as a non-logged operation, so your database (Oracle, MS SQL Server, Sybase), although unlikely, may not allow it (depends on the administrator). However, this method always works in Access or on .MDB files.