SQL Data Manipulation Statement

From GM-RKB
Jump to navigation Jump to search

A SQL Data Manipulation Statement is a Data Manipulation Statement that is a SQL statement (within a SQL language).



References

2013

  • http://en.wikipedia.org/wiki/SQL#Data_manipulation
    • The Data Manipulation Language (DML) is the subset of SQL used to add, update and delete data:
      • INSERT adds rows (formally tuples) to an existing table, e.g.: <source lang="sql"> INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL); </source>
      • UPDATE modifies a set of existing table rows, e.g.: <source lang="sql"> UPDATE example SET field1 = 'updated value' WHERE field2 = 'N'; </source>
      • DELETE removes existing rows from a table, e.g.: <source lang="sql"> DELETE FROM example WHERE field2 = 'N'; </source>
      • MERGE is used to combine the data of multiple tables. It combines the INSERT and UPDATE elements. It is defined in the SQL:2003 standard; prior to that, some databases provided similar functionality via different syntax, sometimes called “upsert”. <source lang="sql"> MERGE INTO table_name USING table_reference ON (condition) WHEN MATCHED THEN UPDATE SET column1 = value1 [, column2 = value2 ...] WHEN NOT MATCHED THEN INSERT (column1 [, column2 ...]) VALUES (value1 [, value2 ... </source>