输出没有数据的模式

I'm using a MySql database with a Java program, now I want to give the program to somebody else.

How to export the MySql database structure without the data in it, just the structure?

转载于:https://stackoverflow.com/questions/6175473/mysql-export-schema-without-data

You can do with the --no-data option with mysqldump command

mysqldump -u root -p --no-data dbname > schema.sql

Yes, you can use mysqldump with the --no-data option:

mysqldump -u user -h localhost --no-data -p database > database.sql

You Can Use MYSQL Administrator Tool its free http://dev.mysql.com/downloads/gui-tools/5.0.html

you'll find many options to export ur MYSQL DataBase

You can use the -d option with mysqldump command

mysqldump -u root -p -d databasename > database.sql

you can also extract an individual table with the --no-data option

mysqldump -u user -h localhost --no-data -p database tablename > table.sql

To get an individual table's creation script:
- select all the table (with shift key)
- just right click on the table name and click Copy to Clipboard > Create Statement.

In case you are using IntelliJ you can enable the Database view (View -> Tools Window -> Database)

Inside that view connect to your database. Then you can rightclick the database and select "Copy DDL". Other IDEs may offer a similar function.

IntelliJ DDL

You can take using the following method

mysqldump -d <database name> > <filename.sql> // -d : without data

Hope it will helps you

Dumping without using output.

mysqldump --no-data <database name> --result-file=schema.sql

Beware though that --no-data option will not include the view definition. So if yo had a view like following create view v1 select a.id AS id, a.created_date AS created_date from t1; with --no-data option, view definition will get changed to following create view v1 select 1 AS id, 1 AS created_date