SQL命名法:“Query”或“命令”对于INSERT / UPDATE / DELETE? [英] SQL Nomenclature: "Query" or "Command" for INSERT/UPDATE/DELETE?
问题描述
哪个更适合调用INSERT / UPDATE / DELETE语句?命令还是查询?我认为命令,因为查询意味着你要问一个问题,并希望得到回答你的问题(更多的信息,而不仅仅是是的,这个操作成功执行,并且,可选,这里是你的插入ID) 。
Which is more proper to call INSERT/UPDATE/DELETE statements? Command or query? I would think "command," since "query" implies that you are asking a question and expecting to get your question answered (and more information than just "yes, this operation was performed successfully, and, optionally, here's your insert ID").
只是一个中级Web应用程序开发人员的问题,他也是一个沟通专业,是一个喜欢特殊性的人。 :
Just a question from a mid-level web application developer who was also an communications major and is one who enjoys specificity. :)
推荐答案
INSERT
, UPDATE
, DELETE
和 MERGE
是一个更新是潜在的混乱 - 而不是理想 - UPDATE
只是更新的一个子集)。一个替代术语是关系赋值。
The generic term for a INSERT
, UPDATE
, DELETE
and MERGE
is an "update" (even though it is potentially confusing -- and not ideal -- that UPDATE
is merely a subset of "update"). An alternative term is "relational assignment".
SELECT
,
, UPDATE
, DELETE
, MERGE $ c $
The generic term for SELECT
, INSERT
, UPDATE
, DELETE
, MERGE
(and anything else terminated by a semicolon) is known as a "statement".
严格来说,一个查询是一个 SELECT
返回结果集的语句(例如,会排除 SELECT..INTO..FROM
语句)。然而,使用术语查询来指代更新,而非正式的,不幸的是非常常见。例如,虽然更新查询是一个矛盾,当我使用确切的术语( site:stackoverflow.com更新查询
)的Google搜索得到17,300点击!
Strictly speaking, a "query" is a SELECT
statement that returns a resultset (which would for example preclude SELECT..INTO..FROM
statements). However, using the term "query" to refer to an update, while informal, is unfortunately very common. For example, although "update query" is an oxymoron, when I do a Google search for this site using that exact term (site:stackoverflow.com "update query"
) I get 17,300 hits!
UPDATE(pun indended :)
UPDATE (pun indended :)
@David Marx:我不同意你的说法,将
引用为INSERT / DELETE / MERGE是一个更新。这将是非常
混乱。只有UPDATE是更新。
@David Marx: I disagree with your claim that it's appropriate to refer to INSERT/DELETE/MERGE as an 'update.' That would be extremely confusing. Only UPDATE is an update.
我在原来的答复中同意这种情况可能会引起混淆。我们很幸运Stackoverflow能够格式化答案和注释,以便关键字 UPDATE
可以区别于逻辑更新;
I agreed in my original answer that the situation is potentially confusing. We are fortunate on Stackoverflow to be able to format answers and comments so that a keyword UPDATE
can be differentiated from a logical update; writing keywords in upper case (as required by Full Standard SQL-92 :) also helps.
但是,从阅读一般数据库和计算科学文献,我可以告诉你更新确实是正确的集体术语。下面为此提供一个引用:
However, from reading the general database and computing science literature, I can tell you that 'update' is indeed the correct collective term. I below provide a citation for this:
关系数据库理论介绍(2010),Hugh Darwen [可以作为一个免费的pdf下载 -
"An Introduction to Relational Database Theory" (2010), Hugh Darwen [available as a free pdf download -- Google it):
关系DBMS中预期的不同更新运算符是
,通常称为INSERT
,DELETE
和UPDATE
,这些是教程D中使用的
名称)[p.28]
The different update operators expected in a relational DBMS are usually called
INSERT
,DELETE
andUPDATE
, and those are the names used in Tutorial D (also in SQL) [p.28]
令人遗憾的是,关键字 UPDATE
作为用于更新
数据库的仅一个特定操作符的名称。请不要拍摄信使! [p.168]
It is regrettable that the keyword UPDATE
has become so widely
accepted as the name of just one particular operator for updating
databases. Please don't shoot the messenger! [p.168]
虽然[关系]赋值理论上足以满足
更新的目的,但通常更方便的是使用简写
目标
relvar的当前值和新值之间的差。有时候...差别只是
添加一个或多个元组到现有集合;有时它是
只是改变一些现有的
元组的一些属性值;有时它只是删除一些现有的
元组。这三个特殊情况的缩写已被引用
为 INSERT
, UPDATE
和 DELETE
,因为时间
是免费的 - 换句话说,甚至在关系型
数据库出现之前,虽然当然之前出现
的目标更新是文件,而不是relvars或SQL表[p.165]
although [relational] assignment is theoretically sufficient for
updating purposes, it is usually more convenient to use a shorthand
expressing the difference between the current value of the target
relvar and the new value. Sometimes... that difference is just the
addition of one or more tuples to the existing set; sometimes it is
just changes to some of the attribute values of some of the existing
tuples; and sometimes it is just the removal of some of the existing
tuples. Shorthands for those three particular cases have been referred
to as INSERT
, UPDATE
and DELETE
respectively, since time
immemorial -- in other words, even before the advent of relational
databases, though of course before that advent the targets of the
updates were files, not relvars or SQL tables [p.165]
这篇关于SQL命名法:“Query”或“命令”对于INSERT / UPDATE / DELETE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!