Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallNOT NULL prevents a column from containing SQL NULL; it does not validate whether other values are sensible, correctly formatted, or allowed by your application. An empty string, zero, or the text 'unknown' is still non-null. Use additional constraints that match the rule you need.
What NOT NULL actually guarantees
A NOT NULL constraint rules out one specific value: SQL NULL, which represents missing or unknown data. PostgreSQL’s documentation describes it as requiring that a column not assume the null value, and says explicit NOT NULL is more efficient in PostgreSQL than the equivalent CHECK (column_name IS NOT NULL). PostgreSQL 18: Constraints
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
Grokking Relational Database Design | $38.11 | Buy on Amazon |
| 2 |
|
Learning SQL: Generate, Manipulate, and Retrieve Data | $36.49 | Buy on Amazon |
| 3 |
|
Practical SQL, 2nd Edition: A Beginner's Guide to Storytelling with Data | $19.99 | Buy on Amazon |
| 4 |
|
SQL Database Query Programmer T-Shirt | $19.99 | Buy on Amazon |
It does not say that every value left in the column is valid. Depending on the column’s type and the database’s rules, values such as '', 0, or 'unknown' may be non-null and therefore satisfy NOT NULL, even if your application considers them unusable. MySQL’s documentation, for example, treats NULL and the empty string as distinct values. MySQL 8.4: Problems with NULL Values
Choose a constraint for the rule you need
Start by stating the invariant plainly: must a value be present, meet a condition, be unique, or refer to an existing row? Those are different requirements, and they call for different mechanisms.
#1 Best Overall
| Requirement | Typical mechanism | What to watch for |
|---|---|---|
| A value must be supplied | NOT NULL |
Stops SQL NULL, not arbitrary non-null content. |
| A value must satisfy a condition on its row | CHECK |
Handle NULL explicitly; combine with NOT NULL when presence is required. |
| A value must not duplicate another row’s value | UNIQUE |
Details, including how NULL is treated, can vary by implementation. |
| A value must refer to an existing row | FOREIGN KEY |
A nullable reference may need its own NOT NULL constraint if the relationship is mandatory. |
PostgreSQL describes CHECK as a general way to constrain row values. It cautions that a check is intended for conditions on the row being inserted or updated—not as a guarantee across other rows or tables, since later changes can invalidate such a condition. Foreign keys are the appropriate relational mechanism for references to rows in another table. PostgreSQL 18: Constraints PostgreSQL 18: Check Constraints Microsoft: Unique constraints and check constraints
Why a CHECK may still allow NULL
SQL conditions can evaluate to TRUE, FALSE, or UNKNOWN. When a value in the condition is NULL, the result may be UNKNOWN. PostgreSQL and MySQL 8.4 document that a CHECK accepts TRUE or UNKNOWN and rejects FALSE; SQL Server likewise warns that a NULL can make a check expression UNKNOWN, avoiding an error. PostgreSQL 18: Constraints MySQL 8.4: CHECK Constraints Microsoft: Unique constraints and check constraints
That is why CHECK (price > 0) alone does not necessarily require a price to be present. If a missing price is forbidden, pair the condition with NOT NULL. The same principle applies to any check where both presence and a valid value matter.
Example: require a positive price and a non-empty name
This PostgreSQL-style illustration makes presence and row-local value rules explicit:
CREATE TABLE products (
product_id integer PRIMARY KEY,
name text NOT NULL CHECK (length(name) > 0),
price numeric NOT NULL CHECK (price > 0)
);
The price must be present and greater than zero. The name must be present and have a length greater than zero. If whitespace-only names are invalid, that rule needs to be expressed as well: a non-empty string is not necessarily meaningful text. Empty-string, whitespace, collation, type-coercion, and function behavior can differ between database engines, so check the documentation for the engine and version you deploy before adopting the exact expression.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Engine behavior and configuration matter
The general distinction between presence and validity applies broadly, but exact behavior is not identical across database products or configurations.
Rank #4
- Database Programming design. Funny database SQL joke that makes a great gift for database administrators, programmers or computer scientists. Fun gift for database administrators, programmers and hackers who like to wear funny nerd clothes.
- Funny gift for men and women who love SQL. The perfect SQL Query top for programmers, hackers and SQL database fans who love relational databases.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
- PostgreSQL 18: explicit
NOT NULLis documented as more efficient than the equivalent check, and aCHECKpasses when its expression is true or null. PostgreSQL 18: Constraints - MySQL 8.4: a
CHECKsucceeds forTRUEorUNKNOWNand fails forFALSE. MySQL 8.4: CHECK Constraints - SQL Server: its documentation notes that
CHECKrejectsFALSE, while aNULLmay make the expressionUNKNOWN. Microsoft: Unique constraints and check constraints - MySQL 8.0 input handling: strict SQL mode affects how invalid data is handled. The manual warns that disabling strict mode can allow invalid values to be coerced and says this forgiving behavior is not recommended. Check the active SQL mode when investigating apparently accepted input. MySQL 8.0: SQL Modes
Before relying on a rule, test it on the deployed engine and version with both NULL and representative invalid non-null values. For MySQL, inspect the server’s active SQL mode as well as the constraint definition.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →




