This time mysqldump may not be very good, use the following method can solve this problem.
Method One, insert, and select in conjunction with
1, create a new table, such as New-table, contains the name of the field to be exported, such as A,b,c
2. Use INSERT into new-table (a,b,c) select A,b,c from old-table;
3, the remaining step is to export the new table, and then the text processing
Method Two, use the MySQL SELECT INTO OutFile Backup statement (recommended)
In the following example, a file is generated with the values separated by commas. This format can be used by many programs.
Copy Code code as follows:
SELECT a,b,a+b into outfile '/tmp/result.text '
FIELDS terminated by ', ' optionally enclosed by ' '
LINES terminated by ' \ n '
From Test_table;
See details of how select is used
Copy Code code as follows:
Select subject into Outlifile '/tmp/xiaoruizi.text ' fields terminated by ' \ t ' optionally enclosed by ' "' lines terminated By ' \ n ' from Pw_blog;
Method Iii. use of mysqldump
It's amazing that I found out that mysqldump actually had a very good parameter, "-W."
Instructions on the Help document:
Copy Code code as follows:
-w|–where=
Dump only selected records; Quotes mandatory!
So is it possible to use this parameter to derive some values? For example, I just need to export some data with ID greater than 2312387:
Copy Code code as follows:
Mysqldump-u root-p bbscs6 bbscs_userinfo–where "id>2312387" > Bbscs_userinfo-par.sql