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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 21, 2012, 1:52 AM EST
SELECT TOP 0 * INTO employee1 FROM employee
VulpesRank #55 · 29.2K reputationPosted Nov 21, 2012, 1:54 AM EST
SELECT * INTO newTable FROM oldTable WHERE 0 = 1
As the WHERE clause always returns false, no records are copied just the structure : )
Shankar MRank #874 · 2.5K reputationPosted Nov 27, 2012, 1:19 AM EST
In Oracle:
CREATE TABLE TABLE_X
AS
SELECT * FROM table_y WHERE 1=0;
Thanks,
Shankar