当前位置:网站首页>Export MySQL table data in pure mode

Export MySQL table data in pure mode

2022-07-06 22:27:00 Maple Leaf pear flower

Sometimes I want to guide my watch , Is to export the data of a table , Then import to another table , But directly mysqldump The table data exported by this command , Not clean enough , Can't import directly , So use some parameters to filter information . The following statement can export data cleanly

mysqldump -uroot -h 127.0.0.1 -proot --databases test --tables user_info --where "id > 3" --default-character-set gbk --skip-comments --no-create-info --no-create-db --skip-add-drop-table  --skip-add-locks --skip-disable-keys   --skip-extended-insert --set-gtid-purged=off -c > C:\Users\Breeze\Desktop\test.sql

Data in the original table
 Insert picture description here
Derived SQL File data


/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES gbk */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;

INSERT INTO `user_info` (`id`, `name`, `age`) VALUES (4,'Dave',24);
INSERT INTO `user_info` (`id`, `name`, `age`) VALUES (5,'Eva',24);
INSERT INTO `user_info` (`id`, `name`, `age`) VALUES (6,'Maybe',27);
/*!40103 SET [email protected]_TIME_ZONE */;

/*!40101 SET [email protected]_SQL_MODE */;
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;
/*!40014 SET [email protected]_UNIQUE_CHECKS */;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
/*!40111 SET [email protected]_SQL_NOTES */;

Aforementioned SQL The file is relatively clean SQL Script statements

  • --default-character-set gbk Set the encoding set , Prevent Chinese data from being garbled
  • --skip-comments Uncomment information
  • --no-create-info Export data only , Do not export table creation statements
  • --no-create-db Export data only , Do not export database creation statements
  • --skip-add-drop-table skip drop sentence
  • -skip-add-locks Cancel adding... Before each table export LOCK TABLES
  • --skip-disable-keys Export less output information ( For debugging ). Get rid of the comments and the head and tail structures . Options available :--skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys
  • --skip-extended-insert Use with multiple VALUES Column INSERT grammar .
原网站

版权声明
本文为[Maple Leaf pear flower]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061428034518.html