Given already created SQL databases, is there any way to generate the DDL SQL statements to recreate the database?
Asked
Active
Viewed 1.6k times
5
-
Your phpmyadmin tag suggests a MySQL database, but please edit your question to include the database type. – Jan Doggen Mar 07 '13 at 10:14
-
The answer to this is different for each DBMS. Could you edit your question to clarify which DBMS this is about? – sleske Mar 07 '13 at 11:08
-
There are lots of GUI tools for different DBs and SQL variants that can do what you want (select tables and export as DDL and data SQL files so everything can be recreated). – Karan Mar 07 '13 at 19:24
2 Answers
9
Given that you have tagged phpMyAdmin, just use the export feature for the whole database. You will be given the option to choose a format, and SQL is one of the options.
mysqldump will do the same thing, with many more options.
user1936123
- 241
- 1
- 2
- 9
7
The statement SHOW CREATE TABLE table_name, with table_name being the name of the table you're interested in, will give you the query executed to create the table, on the column Create table, and with SHOW CREATE DATABASE database, you'll have the query to create the database itself.
Combining the two should allow you to get what you want.