SQL - Data Manipulation

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.:
INSERT INTO My_table (field1, field2, field3) VALUES ('test', 'N', NULL);
  • UPDATE modifies a set of existing table rows, e.g.:
UPDATE My_table SET field1 = 'updated value' WHERE field2 = 'N';
  • DELETE removes existing rows from a table, e.g.:
DELETE FROM My_table WHERE field2 = 'N';
  • 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".
MERGE INTO TABLE_NAME USING table_reference ON (condition) WHEN MATCHED THEN UPDATE SET column1 = value1 WHEN NOT MATCHED THEN INSERT (column1 ) VALUES (value1 [, value2 ...

Read more about this topic:  SQL

Famous quotes containing the words data and/or manipulation:

    This city is neither a jungle nor the moon.... In long shot: a cosmic smudge, a conglomerate of bleeding energies. Close up, it is a fairly legible printed circuit, a transistorized labyrinth of beastly tracks, a data bank for asthmatic voice-prints.
    Susan Sontag (b. 1933)

    The principle that human nature, in its psychological aspects, is nothing more than a product of history and given social relations removes all barriers to coercion and manipulation by the powerful.
    Noam Chomsky (b. 1928)