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);


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.


  1. Syed Naqvi · · Reply

    does it also create table with keys and etc?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: