Create boolean column in MySQL with false as default value?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In MySQL, creating a boolean column with a default of false is straightforward, but it helps to know what "boolean" means in MySQL. BOOLEAN and BOOL are aliases for TINYINT(1), so the database stores 0 and 1 even though the schema reads like a true-or-false field.
Basic Column Definition
The simplest definition is:
This is readable and works as expected:
- '
FALSEis stored as0' - '
TRUEis stored as1' - new rows get
FALSEunless you provide another value
You can verify the behavior:
The result is still numeric under the hood, but semantically it behaves like a boolean flag.
Altering an Existing Table
If the table already exists, add the column like this:
That updates the schema and gives existing rows the default value where appropriate, subject to the engine and version behavior during the migration.
Why BOOLEAN Works Even Though MySQL Has No Native Boolean Type
MySQL accepts:
- '
BOOLEAN' - '
BOOL'
but internally treats them as TINYINT(1). That means these definitions are effectively equivalent:
Most developers prefer BOOLEAN because the schema communicates intent better.
Querying and Updating Boolean Columns
Once the column exists, you can write readable statements:
Because the values are stored as 0 and 1, queries using numeric literals also work:
Still, TRUE and FALSE are usually clearer in application-facing SQL.
Enforcing Strict Boolean Semantics
Since the underlying type is numeric, MySQL can technically store values other than 0 and 1 unless you constrain the column. In modern MySQL versions, a check constraint can enforce that rule:
This is helpful if you want to protect against accidental writes such as 2 or -1.
Common Pitfalls
The most common mistake is assuming MySQL has a separate physical boolean type. It does not. BOOLEAN is an alias, so tools and drivers may still show the column as TINYINT.
Another mistake is leaving the column nullable when the business rule is really true-or-false. If NULL is allowed, you now have a third state: unknown. That may be useful, but it is not the same as a normal boolean flag.
A third issue is relying on truthy semantics without consistency in application code. If one part of the application writes 1 and another writes TRUE, that is fine. If something writes 2, your logic may behave unpredictably unless you enforce allowed values.
Finally, be careful with old data migrations. Adding NOT NULL DEFAULT FALSE to a large table may lock or rewrite data depending on the MySQL version, storage engine, and migration strategy. The SQL is simple, but the operational impact can still matter.
Summary
- Use
BOOLEAN NOT NULL DEFAULT FALSEfor a readable MySQL boolean-style column. - MySQL stores boolean values as
TINYINT(1)under the hood. - '
FALSEmaps to0, andTRUEmaps to1.' - Prefer
NOT NULLunless you intentionally want a third unknown state. - Add a check constraint if you want to enforce only
0and1.

