Reputation: 7345
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
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
Reputation: 10302
SHOW CREATE TABLE table_x;
...will output one record with the CREATE syntax. Is that what you're looking for?
Upvotes: 0