MySql export schema without data

2020-01-25 02:59发布

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?

标签: mysql sql
11条回答
混吃等死
2楼-- · 2020-01-25 03:29

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

mysqldump -u root -p --no-data dbname > schema.sql
查看更多
Root(大扎)
3楼-- · 2020-01-25 03:32

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

查看更多
神经病院院长
4楼-- · 2020-01-25 03:36

Dumping without using output.

mysqldump --no-data <database name> --result-file=schema.sql
查看更多
啃猪蹄的小仙女
5楼-- · 2020-01-25 03:37

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

mysqldump -u user -h localhost --no-data -p database > database.sql
查看更多
甜甜的少女心
6楼-- · 2020-01-25 03:37

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.

查看更多
Explosion°爆炸
7楼-- · 2020-01-25 03:40

You can take using the following method

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

Hope it will helps you

查看更多
登录 后发表回答