Deleting rows · Eliminar filas
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.
Eliminar filas con DELETE
DELETE elimina las filas que coinciden con una condición WHERE:
DELETE FROM product WHERE code = 'P03';
Solo se eliminan las filas coincidentes; la tabla y sus demás filas permanecen.
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 misma advertencia
Al igual que UPDATE, un DELETE sin WHERE afecta todas las filas:
DELETE FROM product; -- empties the whole table!
Siempre revise su WHERE antes de ejecutar un DELETE. El verificador ejecuta su DELETE, luego lee la tabla de nuevo para confirmar que la fila correcta ha desaparecido.
Common mistakes
DELETEwithout aWHEREempties the table — always add theWHERE.- Test a risky delete first as a
SELECTwith the sameWHERE.
Errores comunes
DELETEsin unWHEREvacía la tabla — siempre agregue elWHERE.- Pruebe primero una eliminación arriesgada como un
SELECTcon el mismoWHERE.
Delete the product with code 'P03' from the product table. (Afterwards only P01 and · y P02 remain.) · Elimine el producto con código 'P03' de la tabla product. (Después, solo quedan P01 y P02.)
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
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 puede usar cualquier condición. Elimine todos los productos que cuesten menos de 2.00 con WHERE price < 2.00. Solo va la Pluma (0.80); revise qué filas permanecen.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.