SQL: How to copy just table structure or create a table from another table without copying any values from the old table?


Here’s how it can be done:

CREATE TABLE new_table
AS (SELECT * FROM old_table WHERE 1=2);

Eg:

CREATE TABLE student
AS (SELECT * FROM person WHERE 1=2);

This would create a new table called student that includes all columns from the person table, but no data from the person table.

About these ads

About this entry