Copy table without copying data

Matthew picture Matthew · Dec 2, 2009 · Viewed 131.4k times · Source
CREATE TABLE foo SELECT * FROM bar

copies the table foo and duplicates it as a new table called bar.

How can I copy the schema of foo to a new table called bar without copying over the data as well?

Answer

RCNeil picture RCNeil · Sep 10, 2013

Try

CREATE TABLE foo LIKE bar;

so the keys and indexes are copied over as, well.

Documentation