问题描述
INSERT INTO table VALUES ..
和 INSERT INTO table SET
的主要区别是什么?
What is main difference between INSERT INTO table VALUES ..
and INSERT INTO table SET
?
示例:
INSERT INTO table (a, b, c) VALUES (1,2,3)
INSERT INTO table SET a=1, b=2, c=3
那两人的表现呢?
推荐答案
据我所知,两种语法是等效的.第一个是SQL标准,第二个是MySQL的扩展.
As far as I can tell, both syntaxes are equivalent. The first is SQL standard, the second is MySQL's extension.
所以它们在性能方面应该完全相同.
So they should be exactly equivalent performance wise.
http://dev.mysql.com/doc/refman/5.6/en/insert.html 说:
INSERT 将新行插入到现有表中.语句的 INSERT ... VALUES 和 INSERT ... SET 形式基于显式指定的值插入行.INSERT ... SELECT 表单插入从另一个表或多个表中选择的行.
INSERT inserts new rows into an existing table. The INSERT ... VALUES and INSERT ... SET forms of the statement insert rows based on explicitly specified values. The INSERT ... SELECT form inserts rows selected from another table or tables.
这篇关于MySQL INSERT INTO table VALUES.. vs INSERT INTO table SET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!