简体   繁体   English

INSERT INTO表与INSERT INTO表SET吗?

[英]INSERT INTO table vs INSERT INTO table SET?

Okay so I'm really new to SQL and I am using mySQL Workbench. 好吧,所以我真的是SQL新手,正在使用mySQL Workbench。 I found some code that works for me but from what I've read on w3schools I didn't not see it. 我找到了一些对我有用的代码,但是从我在w3schools上阅读的内容来看,我没有看到它。 The code is INSERT INTO servers SET ? 代码是INSERT INTO servers SET ? (where servers is the table). (其中服务器是表)。 But I have read INSERT INTO servers is there any actual difference between these two? 但是我已经读过INSERT INTO servers ,两者之间有什么实际区别? Is any of them preferred? 是其中的任何一个吗? What does the SET ? SET ? mean? 意思?

The preferred -- or at least standard -- method is: 首选(或至少是标准)方法是:

insert into servers ( . . . )

followed by either values or select . 然后是valuesselect The columns being updated are in the parenthesis. 要更新的列在括号中。

MySQL has extended this syntax. MySQL扩展了此语法。 It follows the same convention as update . 它遵循与update相同的约定。 The set syntax makes it easier to see what value is being assigned to which columns. 使用set语法可以更轻松地查看将哪些值分配给哪些列。 That is definitely an advantage. 那绝对是优势。 But working against the syntax is the simple fact that it is not standard. 但是,与语法冲突是一个不标准的简单事实。

If you are learning SQL, learn the standard syntax and remember to always list the columns. 如果要学习SQL,请学习标准语法并记住始终列出各列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM