SQL Nomenclature: “Query” or “Command” for INSERT / UPDATE / DELETE?

Which is more suitable for calling INSERT / UPDATE / DELETE statements? A team? I think the “team” as the “request” implies that you are asking a question and expect an answer to your question (and more information than just “yes”, this operation was successful and, optionally, your insert identifier is here).

Just a question from the middle-level web application developer, who was also a major communicator, and the one who uses the specifics. :)

+7
source share
3 answers

The generic term for INSERT , UPDATE , DELETE and MERGE is “update” (although it is potentially confusing rather than perfect) that UPDATE is just a subset of “update”). An alternative term is “relational assignment”.

The general term for SELECT , INSERT , UPDATE , DELETE , MERGE (and everything that ends with a semicolon) is called a "statement".

Strictly speaking, a "query" is a SELECT that returns a result set (which, for example, would exclude SELECT..INTO..FROM ). However, the use of the term “request” to refer to an update, although unofficially, is unfortunately very common. For example, although the "update request" is an oxymoron, when I do a Google search for this site using this exact term ( site:stackoverflow.com "update query" ), I get 17,300 hits!


UPDATE (pun intended :)

@David Marx: I do not agree with your statements that for INSERT / DELETE / MERGE as an “update”. That would be extremely confusing. Only the UPDATE update is an update.

I agreed in my initial answer that the situation is potentially confusing. We are fortunate that Stackoverflow will be able to format responses and comments so that the UPDATE keyword can be distinguished from a logical update; and also helps to write keywords in upper case (as required by Full Standard SQL-92 :).

However, after reading a general database and computational scientific literature, I can tell you that “updating” is indeed the right collective term. Below I will quote for this:

"Introduction to Relational Database Theory" (2010), Hugh Darwen [available as a free download in PDF format - Google it):

The various update statements expected in a relational DBMS, commonly called INSERT , DELETE and UPDATE , are the names used in Tutorial D (also in SQL) [p. 28]

Unfortunately, the UPDATE keyword has become so widely accepted as the name of only one particular statement to update the database. Please do not shoot the messenger! [P .168]

although the [relational] theorem 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 ... this difference is simply adding one or more tuples to an existing set; sometimes it’s just changes to some attribute values ​​of some existing tuples; and sometimes it's just deleting some of the existing tuples. The abbreviations for these three special cases were transferred to INSERT , UPDATE and DELETE respectively, since the time immemorial was, in other words, even before the appearance of the relational database, although, of course, before this coming of the target, the files were updates, not relvars or SQL tables [ p .165]

+5
source

If in doubt, call it "expression."

+4
source

Sometimes, except select, it is considered DML - a language for manipulating data. However, it is not difficult and fast. This is also often selected in DML.

0
source

All Articles