If you want to throw an error in the code part (not sql), your option is only
$result = db.query("SELECT count(1) FROM table WHERE column_that_should_not_be_null IS NULL")
assert($result = 0);
If you want to convert a column so that it doesnβt accept NULLwhen you execute ALTER TABLE ... SET NOT NULL, you will receive an error message.
source
share