MYsql數據文本形式導出與導入 一、查詢表結構 mysql> desc province; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(32) | NO | | NULL | | | countryId | int(11) | YES | MUL | NULL | | +-----------+-------------+------+-----+---------+----------------+ 二、表中數據導出為文本文件(.txt) Sql代碼 select id,name,countryId into outfile"d:/data_out.txt" lines terminated by "\r\n" from province; 導出結果: 1 北京 1 2 上海 1 3 天津 1 4 重慶 1 5 黑龍江 1 6 吉林 1 7 遼寧 1 …… 三、文本文件導入數據庫 Sql代碼 load data local infile "d:/data_out.txt" into table t_province(id,name); 導入結果: mysql> select * from t_province; +----+--------+ | id | name | +----+--------+ | 1 | 北京 | | 2 | 上海 | | 3 | 天津 | | 4 | 重慶 | | 5 | 黑龍江 |