We can use the mysql command mode to import or export csv files. If you need it, you can simply refer to it.
Mysql> select * from tt_address;
+ ----- + -------- + ------ + -------- + ------------ + ------------- + ------
----- + ---------- + ------- + ---------------------- + ------- + -------- + ----- + -------
-- + ---------- + ------ + --------- + ------ + ----- + -------- + --------- + ------- + ----- + ---
------ + ------------- + -------------- + --------------------------- + ----------------
------- +
| Uid | pid | tstamp | hidden | name | gender | first_name | middle_name | last _
Name | birthday | title | email | phone | mobile | www | addres
S | building | room | company | city | zip | region | country | image | fax | de
Leted | description | addressgroup | module_sys_dmail_category | module_sys_dmai
Rochelle HTML |
+ ----- + -------- + ------ + -------- + ------------ + ------------- + ------
----- + ---------- + ------- + ---------------------- + ------- + -------- + ----- + -------
-- + ---------- + ------ + --------- + ------ + ----- + -------- + --------- + ------- + ----- + ---
------ + ------------- + -------------- + --------------------------- + ----------------
------- +
| 2 | 42 | 0 | 1 | m | aa
| 0 | tian.li@atop-online.de |
| D |
0 | 0 | 0 |
0 |
+ ----- + -------- + ------ + -------- + ------------ + ------------- + ------
----- + ---------- + ------- + ---------------------- + ------- + -------- + ----- + -------
-- + ---------- + ------ + --------- + ------ + ----- + -------- + --------- + ------- + ----- + ---
------ + ------------- + -------------- + --------------------------- + ----------------
------- +
1 row in set (0.00 sec)
There is only one piece of data in this table. Now, the exported csv file only needs uid, name, gender, email, and module_sys_dmail_html. the command line is as follows: select uid, name, gender, email, module_sys_dmail_html into outfile 'd: \ test7.csv 'fields terminated ', 'optionally enclosed by '"'Lines terminated by 'n' from tt_address
Run the following command to import a cvs file to the MySql database:
Mysql> load data local infile 'e: \ input1.csv 'into table test1 fields terminated by', 'Lines terminated by 'n' (first_name, last_name, email );
Fields terminated by ---- field Terminator
Fields optionally enclosed by ---- envelope character
Lines terminated by ---- line terminator