Deleting rows · Suppression de lignes
Removing rows with DELETE
DELETE removes the rows that match a WHERE condition:
Only the matching rows are removed; the table and its other rows stay.
Supprimer des lignes avec DELETE
DELETE supprime les lignes qui correspondent à une condition WHERE :
DELETE FROM product WHERE code = 'P03';
Seules les lignes correspondantes sont supprimées ; la table et ses autres lignes restent.
The same warning
Like UPDATE, a DELETE with no WHERE hits every row:
Always check your WHERE before running a DELETE. The checker runs your DELETE, then reads the table back to confirm the right row is gone.
La même mise en garde
Comme UPDATE, un DELETE sans WHERE touche toutes les lignes :
DELETE FROM product; -- empties the whole table!
Vérifiez toujours votre WHERE avant d'exécuter un DELETE. Le vérificateur exécute votre DELETE, puis lit la table à nouveau pour confirmer que la bonne ligne a disparu.
Common mistakes
DELETEwithout aWHEREempties the table — always add theWHERE.- Test a risky delete first as a
SELECTwith the sameWHERE.
Erreurs courantes
DELETEsans unWHEREvide la table — ajoutez toujours leWHERE.- Testez une suppression risquée d'abord comme un
SELECTavec le mêmeWHERE.
Delete the product with code 'P03' from the product table. (Afterwards only P01 and · et P02 remain.) · Supprimez le produit avec le code 'P03' de la table product. (Après, seuls P01 et P02 restent.)
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
Delete can use any condition. Remove every product that costs less than 2.00 with WHERE price < 2.00. Only the Pen (0.80) goes; check which rows remain. · Delete peut utiliser n'importe quelle condition. Supprimez chaque produit qui coûte moins de 2.00 avec WHERE price < 2.00. Seul le Stylo (0.80) est supprimé ; vérifiez quelles lignes restent.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.