MySQL的load data命令可以将文本文件的数据导入到表
有文本文件如下:
E:\>more test.txt
1,XX,M
2,YY,F
在mysql里创建表t
mysql> create table t(id int,name varchar(10),sex varchar(1));
Query OK, 0 rows affected (0.62 sec)
mysql> load data infile 'e:\\test.txt' into table t fields terminated by ',';
Query OK, 2 rows affected, 2 warnings (0.10 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 2
mysql> select * from t;
++++
| id | name | sex |
++++
| 1 | XX | M |
| 2 | YY | F |
++++
2 rows in set (0.05 sec)
另外,mysqlimport 也可以将文本文件导入到表