Deleting rows · Apagando linhas
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.
Removendo linhas com DELETE
DELETE remove as linhas que correspondem a uma condição de WHERE:
DELETE FROM product WHERE code = 'P03';
Apenas as linhas correspondentes são removidas; a tabela e suas outras linhas permanecem.
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.
O mesmo aviso
Assim como UPDATE, um DELETE sem WHERE atinge todas as linhas:
DELETE FROM product; -- empties the whole table!
Sempre verifique seu WHERE antes de executar um DELETE. O verificador executa seu DELETE, depois lê a tabela de volta para confirmar que a linha certa foi removida.
Common mistakes
DELETEwithout aWHEREempties the table — always add theWHERE.- Test a risky delete first as a
SELECTwith the sameWHERE.
Erros comuns
DELETEsem umWHEREesvazia a tabela — sempre adicione oWHERE.- Teste uma exclusão arriscada primeiro como um
SELECTcom o mesmoWHERE.
Delete the product with code 'P03' from the product table. (Afterwards only P01 and · e P02 remain.) · Apague o produto com código 'P03' da tabela product. (Depois restarão apenas P01 e P02.)
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
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 pode usar qualquer condição. Remova todos os produtos que custam menos de 2.00 com WHERE price < 2.00. Apenas a Caneta (0.80) será removida; verifique quais linhas permanecem.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.