Export Create Table Scripts on MySQL
If you’re coming from another database environment such as Microsoft SQL Server and you’re looking to generate create table scripts on Windows with MySQL, you may want to consider the following options …
-
mysqldump.exe
From the command prompt, navigate to your MySQL bin directory and use the mysqldump.exe command-line application as follows…
mysqldump -u USER --password="MYPWD" DBNAME --no-data > create_tables.sql
If you leave off the –no-data argument, mysqldump will dump the entire database into the create script. The mysqldump.exe documentation explains all the possible arguments and there are very useful user comments/scripts at the bottom of the online documentation page.
To bring a database script back into MySQL:
mysql.exe DBNAME < create_tables.sql
Within MySQL Query Browser, right click on a particular table (under a particular database in the Schemata treeview) and select "Copy CREATE statement to clipboard." This option will allow you to copy and paste the MySQL create table script into your favorite text editor.
Also, while inside the MySQL Query Browser, you can open a new Script tab under "File-> New Script Tab" (or by pressing Ctrl + Shift + T). Once the script tab is open, drag tables onto the script tab to generate the CREATE TABLE script.
More useful links and information concerning how to generate MySQL create table scripts...
- mysqldump.exe documentation - all command-line options explained and useful comments at the bottom of the page.
- MySQL Query Browser: The Script Editor - Windows application for executing MySQL queries, etc.
- MySQL Client Programs documentation - more useful MySQL command-line applications explained.

