| Goal | This query identifies a severe logical contradiction in the database schema. It finds situations where a column is strictly defined as NOT NULL (either directly or inherited via a domain), but is simultaneously subject to a CHECK constraint that explicitly requires the value to be missing (e.g., containing an IS NULL condition). This conflict—whether applied as a single-column or multi-column constraint—creates a logical impossibility, preventing any valid data insertion into the table. The query outputs the schema name, table name, column name, domain name (if applicable), the column's mandatory status, and the definition of the problematic CHECK constraint. |
|---|---|
| Type | Problem detection Each row in the result could represent a flaw in the design |
| Reliability | Medium Medium number of false-positive results |
| License | MIT (opens in new tab) |
| Data Source | INFORMATION_SCHEMA only |
| SQL Query |
|
Fixing Suggestion
To resolve this critical issue, you must eliminate the logical contradiction by reviewing the business requirements for the flagged column. If the column must genuinely hold a value, drop the conflicting CHECK constraint (or modify its boolean expression to remove the IS NULL condition). Conversely, if the column is intentionally meant to be empty or conditionally optional, remove the NOT NULL constraint from the column (or domain) and adjust the CHECK logic accordingly.
Collections
This query belongs to the following collections:
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
| Name | Description |
|---|---|
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
Categories
This query is classified under the following categories:
CHECK constraints
Queries of this category provide information about CHECK constraints.
Missing data
Queries of this category provide information about missing data (NULLs) in a database.
| Name | Description |
|---|---|
| CHECK constraints | Queries of this category provide information about CHECK constraints. |
| Missing data | Queries of this category provide information about missing data (NULLs) in a database. |