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:

    Mental health data from the 1950’s on middle-aged women showed them to be a particularly distressed group, vulnerable to depression and feelings of uselessness. This isn’t surprising. If society tells you that your main role is to be attractive to men and you are getting crow’s feet, and to be a mother to children and yours are leaving home, no wonder you are distressed.
    Grace Baruch (20th century)

    Denotation by means of sounds and markings is a remarkable abstraction. Three letters designate God for me; several lines a million things. How easy becomes the manipulation of the universe here, how evident the concentration of the intellectual world! Language is the dynamics of the spiritual realm. One word of command moves armies; the word liberty entire nations.
    Novalis [Friedrich Von Hardenberg] (1772–1801)