Delete * FROM TABLE

DELETE FROM table_name
WHERE id IS NOT NULL

There may come a time when you need to delete all rows from a database table.

In the event that you can do this you could simple write the following statement:

DELETE FROM table_name
WHERE id IS NOT NULL

Of course this assumes that you have an id field in your table. If your table does not have an id column you could run this across another column:

DELETE FROM table_name
WHERE column IS NOT NULL

And of course this is only going to delete all records where that column is not null, so if you run this using a column that does not allow null, you can be gauranteed that it will remove all columns from that table.

BETA Snippet explanation automatically generated by OpenAI:

No explanation generated yet.

Snippet By Dev Dojo

·

Created June 12th, 2021

·

Report Snippet