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 this entry
You’re currently reading “SQL: How to copy just table structure or create a table from another table without copying any values from the old table?,” an entry on Singaram's Tech Musings
- Published:
- June 20, 2011 / 11:12 PM
- Tags:
- Select (SQL), Tables

No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]