Copy the structure of a table without copying the data in SQL
How will you copy the structure of a table without copying the data in SQL?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shankar MPosted Nov 27, 2012, 6:19 AM
In Oracle:
CREATE TABLE TABLE_X
AS
SELECT * FROM table_y WHERE 1=0;
Thanks,
Shankar
VulpesPosted Nov 21, 2012, 6:54 AM
SELECT * INTO newTable FROM oldTable WHERE 0 = 1
As the WHERE clause always returns false, no records are copied just the structure : )
Satyapriya NayakPosted Nov 21, 2012, 6:52 AM
SELECT TOP 0 * INTO employee1 FROM employee