I have a table with two columns: id (unique key) and data.
I need to delete a row from that table with id equal to some value. Obvious query:
DELETE FROM table WHERE id = value
However, I need to prevent the table from becoming empty (i.e. without rows). In other words, I need to delete the row with id = value only if the table won't become empty after such a deletion.
I need to do it atomically in a single query, I also need to know by the result of this query whether something has been actually deleted or not.
Is it possible?
Thank you.