Sử dụng một lệnh INSERT nhiều hàng (multi-row insert). Cú pháp:
insert into yourTableName values(val1,val2,...),(val1,val2,...),...;
Tạo bảng:
mysql> create table DemoTable2007 ( Amount1 int, Amount2 int, Amount3 int ); Query OK, 0 rows affected (1.36 sec)
Chèn 5 hàng cùng lúc:
mysql> insert into DemoTable2007 values(450,600,700),(1000,200,3000),(800,900,1200),(1300,1500,2000),(40000,50000,6700); Query OK, 5 rows affected (0.11 sec) Records: 5 Duplicates: 0 Warnings: 0
Hiển thị dữ liệu:
mysql> select * from DemoTable2007;
+---------+---------+---------+ | Amount1 | Amount2 | Amount3 | +---------+---------+---------+ | 450 | 600 | 700 | | 1000 | 200 | 3000 | | 800 | 900 | 1200 | | 1300 | 1500 | 2000 | | 40000 | 50000 | 6700 | +---------+---------+---------+ 5 rows in set (0.00 sec)