Initial data (total 6 records)
Username |
Userpwd |
Age |
Admin |
Admin |
18 |
Root |
Root |
18 |
Cat |
Cat |
17 |
Dog |
Dog |
15 |
Dog1 |
Dog1 |
15 |
Zhu |
Zhu |
21st |
two creating a database, creating a table user
Create DatabaseYouku--Create a database UseYouku--Select DatabaseDROP TABLE IF EXISTS`User`;CREATE TABLE`User' (' username 'varchar( One)DEFAULT NULL, ' userpwd 'varchar( One)DEFAULT NULL, ' age 'int( One)DEFAULT NULL) ENGINE=InnoDBDEFAULTCHARSET=UTF8;//Inserting DataINSERT into`User`VALUES('Admin','Admin', -),('Root','Root', -),('Cat','Cat', -),('Dog','Dog', the),('Dog1','Dog1', the),('Zhu','Zhu', +);--table Data ExportSELECT * from User intoOUTFILE'F:/user.txt'; --format the output as needed, each row of data ', ' delimited, and the string type data is enclosed in double quotes ""SELECT * from User intoOUTFILE'F:/user1.txt'Fields TERMINATED by ','Optionally enclosed by '"'; --Table Data Import (note that the number of columns in the imported data corresponds to the columns of the table)--Delete Data First UseYouku;Delete from User whereAge>Ten;Select * from User;LOADDATA INFILE'F:/user.txt' into TABLE User;Select * from User; --Import tables with special formatting user1.txt (remove separator number ', ' and quotation marks of string "") UseYouku;Delete from User whereAge>Ten;Select * from User;LOADDATA INFILE'F:/user1.txt' into TABLE UserFields TERMINATED by ','Optionally enclosed by '"'; Select * from User;
=================
three txt file view
-- table Data Export SELECT * from User into ' F:/user.txt ';
Generate File User.txt
Admin Admin 18
Root root 18
Cat Cat 17
Dog Dog 15
Dog1 Dog1 15
Zhu Zhu 21
-- format the output as needed, each row of data ', ' delimited, and the string type data is enclosed in double quotes "" SELECT * from User into ' F:/user1.txt ' by ', ' by ' "' ;
Generate File User1.txt
"Admin", "admin", 18
"Root", "root", 18
"Cat", "cat", 17
"Dog", "dog", 15
"Dog1", "Dog1", 15
"Zhu", "Zhu", 21
Conclusion: The specific import and export format of data you can try it yourself. However, personal advice involves formatting conversions, so try using other tools first, to prevent errors or to convert only plain text column data (no special formatting).
MySQL data table import and export