Things (about MySQL) my father never told me…

Just discovered one of those things I should have discovered a long, long time ago: in MySQL (and, I assume, every-other-SQL), this:

insert into table (field1,field2,field3) values (1,2,3)
insert into table (field1,field2,field3) values (4,5,6)
insert into table (field1,field2,field3) values (7,8,9)

…can also be expressed like this:

insert into table (field1,field2,field3) values 
                  (1,2,3),
                  (4,5,6),
                  (7,8,9)

The difference is that the second form, especially if you’ve got lots of inserts to do, is much, much faster.

Comments

Add new comment