標籤:mysql
mysql -uroot -p進入資料庫隨便建立一個資料庫create database hangzhou; use hangzhou;
建立個表create table t1 (id int(1),name varchar(20),age char(1),job varchar(20));
在root下建立個檔案1.txt 內容如下,直接用tab隔開:
[[email protected]_168_2_193 ~]# vi 1.txt
1 lx 20 it
4.然後進入資料庫執行load data local infile ‘/root/1.txt‘ into table t1;
5.查看結果:
mysql> show tables;
+--------------------+
| Tables_in_hangzhou |
+--------------------+
| t1 |
+--------------------+
1 row in set (0.00 sec)
mysql> load data local infile ‘/root/1.txt‘ into table t1;
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Deleted: 0 Skipped: 0 Warnings: 1
mysql> select * from t1;
+------+------+------+------+
| id | name | age | job |
+------+------+------+------+
| 1 | lx | 2 | it |
+------+------+------+------+
1 row in set (0.00 sec)
本文出自 “毛毛鴨” 部落格,請務必保留此出處http://woshitieren.blog.51cto.com/2466034/1671684
mysql插入多行資料的方法