INSERT INTO X 2 - Differences

NorseMan

Member
What exactly is the differences between these two? Does it depend on when to use them or is it the same when to use? Do they do, act, and preform the same?

INSERT INTO tableName SET
column1Name = column1Value
column2Name = column2Value

INSERT INTO tableName
(column1Name, column2name)
VALUES (column1Value, column2Value)
 
Are we talking about mysql only?
The first version is mire readable, but the second is preffered as a valid sql implementation. But generally it should works the same
 
If you create a script for small purpose then you can use the more readable option (insert ... set), but for the app where you want to use database as option behind the abstraction/facade then you should use the sql version (insert ... values). The performance should be the same, but you can check it by inserting 10000 or more records and compare the time, it should be almost the same
 
Back
Top