..." statement to export the structure of the database table; 2. Use "mysqldump -uroot -p -B database name --table table name> ..." statement exports the structure of the specified table."/> ..." statement to export the structure of the database table; 2. Use "mysqldump -uroot -p -B database name --table table name> ..." statement exports the structure of the specified table.">

Home >Database >Mysql Tutorial >How to export only the table structure in mysql

How to export only the table structure in mysql

WBOY
WBOYOriginal
2022-05-19 10:59:357566browse

Method: 1. Use the "mysqldump --opt -d database name -u root -p >..." statement to export the structure of the database table; 2. Use "mysqldump -uroot -p -B database Name --table table name>..." statement exports the structure of the specified table.

How to export only the table structure in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How does mysql export only the table structure

mysql mysqldump only exports the table structure but not the data

1. Export the structure but not the data

The code is as follows:

mysqldump --opt -d 数据库名 -u root -p > xxx.sql

2. Export data without exporting the structure

The code is as follows:

mysqldump -t 数据库名 -uroot -p > xxx.sql

3. Export data and tables Structure

The code is as follows:

mysqldump 数据库名 -uroot -p > xxx.sql

4. Export the structure of a specific table

The code is as follows:

mysqldump -uroot -p -B 数据库名 --table 表名 > xxx.sql

Extension Knowledge:

mysqldump is MySQL’s own logical backup tool.

Its backup principle is to connect to the MySQL database through the protocol, query the data that needs to be backed up, and convert the queried data into corresponding insert statements. When we need to restore the data, we only need to execute these inserts statement to restore the corresponding data.

Backup command

Command format

mysqldump [选项] 数据库名 [表名] > 脚本名

or

mysqldump [选项] --数据库名 [选项 表名] > 脚本名

or

mysqldump [选项] --all-databases [选项] > 脚本名

Recommended learning: mysql video tutorial

The above is the detailed content of How to export only the table structure in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn