MySQL INSERT
Syntax comparison: INSERT INTO VALUES
vs. INSERT INTO SET
In MySQL, there are two common syntaxes for inserting values into database tables:
INSERT INTO table (a, b, c) VALUES (1, 2, 3)
INSERT INTO table SET a = 1, b = 2, c = 3the difference:
Both syntaxes can achieve the purpose of inserting new rows into a specified table, but there are slight differences between them:
INSERT INTO ... VALUES
INSERT INTO ... SET is an extension of MySQL that allows you to assign values to columns using the
SETperformance:
There is no significant difference between the two syntaxes in terms of performance. Both can perform insert operations efficiently and have similar execution times.
Which one to choose?
What syntax is used in the end depends on your preferences and the specific context of the database schema.
If you need to adhere to strict SQL standards, or want to write code that is compatible with multiple databases,
INSERT INTO ... VALUESIf you want to optimize readability and simplicity,
INSERT INTO ... SETDisclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3