Insérer, modifier, supprimer

Insérer

INSERT INTO nom_table [(attributs)] VALUES (valeurs)
INSERT INTO nom_table [(attributs)] SELECT ...

Par exemple :

INSERT INTO LANG (CODE, LIBELLE) VALUES
('en_US', 'English'),
('fr_FR', 'Français');

Clé dupliquée

Si on essaie d’insérer une clé primaire qui existe déjà, une erreur est levée.
On peut modifier ce comportement avec

SQLFiddle


Mettre à jour

UPDATE nom_table SET attribut = valeur
  [WHERE condition]
  [ORDER BY attributs]
  [LIMIT count]

Voir l’article sur les sélections pour la description de WHERE, ORDER BY et LIMIT

Exemples :

UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;
UPDATE reservedNicknames
SET id = CONCAT('rename - ', id),
    nickname = CONCAT('rename - ', nickname)
WHERE LENGTH(nickname) <> 8;

Supprimer

DELETE FROM nom_table
  [WHERE condition]
  [ORDER BY attributs]
  [LIMIT count]

Exemples :

DELETE FROM Customers
WHERE CustomerName = 'Alfreds Futterkiste';
DELETE FROM currencies
WHERE LENGTH(code) != 3;