Get the App
SLTechnology News&Howtos  ›  Database  › 

How mysql exports only the table structure

Shulou Source: shulou.com Published: 2022-05-31 10:41:59 09月17日 Update

Today Xiaobian to share with you how mysql only export table structure related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you have some gains after reading this article, let's learn about it together.

Methods: 1. Using "mysqldump --opt -d database name-u root -p >... "statement export database table structure;2, using"mysqldump -uroot -p -B database name--table table name>... "Statement exports the structure of the specified table.

Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.

How does mysql export table structure only?

mysql mysqldump exports only table structures, not data

1. Export structure Do not export data

The code is as follows:

mysqldump --opt -d database name-u root -p > xxx.sql

2. Export data without exporting structure

The code is as follows:

mysqldump -t database name-uroot -p > xxx.sql

3. Export data and table structures

The code is as follows:

database name-urot-p > xxx.sql

4. Export the structure of a specific table

The code is as follows:

mysqldump -uroot -p -B database name--table table name> xxx.sql

Extended knowledge:

mysqldump is MySQL's logical backup tool.

Its backup principle is to connect to MySQL database through protocol, query the data that needs to be backed up, and convert the queried data into corresponding insert statements. When we need to restore these data, as long as these insert statements are executed, the corresponding data can be restored.

backup command

command format

mysqldump [options] database name [table name] > script name

or

mysqldump [options] --database name [options table name] > script name

or

mysqldump [options] --all-databases [options] > Script name above is "mysql how to export only table structure" All the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Data structure database knowledge code backup articles statements scripts content commands logic queries differences big principles backup tools most of them that is tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei MySQL Shulou Information Redmi