NULL is used to represent "no value" and allow that to be distinguished between 1 and 0, true or false, or an empty string versus a string with content. It's similar to nil in Ruby, null in JavaScript or NULL in PHP.

If you define a column as NOT NULL then it won't allow an INSERT without a value for that column being specified. If you have a DEFAULT then this will be applied automatically. If you use an ORM it may fill it in for you with a safe, minimal default.

Columns that can be NULL require an almost insignificant amount of additional storage per row, one bit, to hold the NULL or NOT NULL flag.

Remember that NULL in MySQL is unusual in that it is not greater than, less than, or equal to any other value. This is why IS NULL and IS NOT NULL are required for logical comparisons.

Answer from tadman on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/sql โ€บ need some knowledge on null and not null
r/SQL on Reddit: Need some knowledge on NULL and NOT NULL
December 22, 2021 -
  • Where and why exactly a null is used?

  • What is exactly null and not null? To my understanding Not null we use when its mandatory to insert some value in that field, also when we give check constraint so by default the column will be not null right?

  • By adding new column through alter method default values are null, so how would I be able to insert values in it and is it right to give not null constraint to that new column while adding through alter method, basically when null and when not null to be used?...

god this is so confusing please help me, ik im asking alot but im really confused

๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_notnull.asp
SQL NOT NULL Constraint
The NOT NULL constraint enforces a column to NOT accept NULL values. This enforces a field to always contain a value, which means that you cannot insert a new record, or update a record without adding a value to this field.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
A NULL value represents an unknown, missing, or inapplicable data in a database field. It is not a value itself, but a placeholder to indicate the absence of data.
๐ŸŒ
LearnSQL.com
learnsql.com โ€บ blog โ€บ not-null-constraint-sql
What Is a NOT NULL Constraint in SQL? | LearnSQL.com
In this article, we will cover the NOT NULL constraint, which is used to avoid having NULL values in a column. Remember, a NULL value in a column represents the absence of a defined value.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_ref_not_null.asp
SQL NOT NULL
The NOT NULL constraint enforces a column to not accept NULL values, which means that you cannot insert or update a record without adding a value to this field.
๐ŸŒ
Programiz
programiz.com โ€บ sql โ€บ not-null
SQL NOT NULL Constraint (With Examples)
In SQL, the NOT NULL constraint in a column means that the column cannot store NULL values. In this tutorial, you will learn about the SQL NOT NULL constraint with the help of examples.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ sql-not-null-constraint
SQL NOT NULL Constraint - GeeksforGeeks
September 20, 2021 - All rows insert successfully because EmpID has valid (non-NULL) values. NOT NULL constraint is satisfied, so the database accepts the rows.
๐ŸŒ
CockroachDB Docs
cockroachlabs.com โ€บ docs โ€บ stable โ€บ not-null
NOT NULL constraint
The NOT NULL constraint specifies a column may not contain NULL values. INSERT or UPDATE statements containing NULL values are rejected.
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ not-null-in-sql
What is SQL NOT NULL Constraint? - Scaler Topics
August 4, 2022 - Consider a table called "Cities" that contains information about numerous cities.This table has columns for city ID, name, population, and country. โคTo apply the NOT NULL in sql, some fields must always contain a value.
๐ŸŒ
Hightouch
hightouch.com โ€บ sql-dictionary โ€บ sql-not-null
SQL NOT NULL - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - A NOT NULL constraint in SQL is a database constraint that ensures a column must always contain a value. It prohibits the insertion of NULL values, making it mandatory for every row to have a non-null value in the specified column.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ home โ€บ sql โ€บ sql not null constraint
SQL NOT NULL Constraint
November 29, 2009 - A NULL is not the same as no data, rather, it represents unknown data. For example, the following SQL query creates a new table called CUSTOMERS and adds five columns, three of which, are ID NAME and AGE, In this we specify not to accept NULLs โˆ’
๐ŸŒ
SQL Shack
sqlshack.com โ€บ commonly-used-sql-server-constraints-not-null-unique-primary-key
Constraints in SQL Server: SQL NOT NULL, UNIQUE and SQL PRIMARY KEY
June 16, 2021 - A NOT NULL constraint in SQL is used to prevent inserting NULL values into the specified column, considering it as a not accepted value for that column. This means that you should provide a valid SQL NOT NULL value to that column in the INSERT ...
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 3240365 โ€บ what-is-the-difference-between-null-and-not-null
What is the difference between null and not null? | Sololearn: Learn to code for FREE!
Rows in the table can have NULL values in this column, which essentially means that the data is missing or unknown for those rows. NOT NULL: When a column is defined as NOT NULL, it means that it must contain a value for every row in the table.
๐ŸŒ
Navicat
navicat.com โ€บ en โ€บ company โ€บ aboutus โ€บ blog โ€บ 1312-the-null-value-and-its-purpose-in-relational-database-systems
The NULL Value and its Purpose in Relational Database Systems
This is what is commonly referred to as a "null pointer". In a database, zero is a value which has meaning, so the value NULL became is a special marker to mean that no value exists.
๐ŸŒ
AlmaBetter
almabetter.com โ€บ bytes โ€บ tutorials โ€บ sql โ€บ not-null-in-sql
NOT NULL in SQL
Not null is a constraint used in SQL that ensures a value is not empty. This is important for businesses and organizations that rely on their databases for day-to-day operations.
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ ias
NOT NULL constraints
NOT NULL constraints prevent null values from being entered into a column.