Check integrity violation in SQL before deleting

My question is like this

I want to check if the DELETE request fails due to a constraint violation. I would like to do this at the database level because I think letting it fail and catching the error is ugly.

Another โ€œmanualโ€ option checks it with SELECT queries to see if there are restrictions, but it's pretty tedious, imho.

Is there a "native" way to do this?

+3
source share
1 answer

The easiest and most direct way is to execute DELETE and catch the error.

SELECT , , ( ). .

, ( , - ).

+3

Source: https://habr.com/ru/post/1772106/


All Articles