domino
domino

Reputation: 7345

Is it possible to pull a table's create syntax via mysql?

I'm looking to pull a table's create syntax via mysql and php. Is it possible?

I need it for a file that creates table_x automatically every 10 days. Since I update the site constantly and create new fields I'd like the file to be dynamic and use the previous table (instead of me updating it manually each time).

Upvotes: 0

Views: 35

Answers (2)

Adrian Cornish
Adrian Cornish

Reputation: 23866

Yes you can - use

SHOW CREATE TABLE tablename;

Actually if you want to 'reset' your database I would use TRUNCATE instead

TRUNCATE TABLE tablename

Upvotes: 2

Thomas Kelley
Thomas Kelley

Reputation: 10302

SHOW CREATE TABLE table_x;

...will output one record with the CREATE syntax. Is that what you're looking for?

Upvotes: 0

Related Questions