
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to create boolean column in MySQL with false as default value?
To create a column with ‘false’ as the default value, we can use the concept of “default” at the time of creation of the table.
Note − 0 represents false and 1 represents true.
Creating a table using “default” false.
mysql> create table TrueFalseTable -> ( -> Adult boolean default false -> ); Query OK, 0 rows affected (0.65 sec)
Inserting records with no value, since we have set “default” above.
mysql> insert into TrueFalseTable values(); Query OK, 1 row affected (0.16 sec)
To display records.
mysql> select *from TrueFalseTable;
The following output shows that the default is set to Boolean false i.e. 0
+-------+ | Adult | +-------+ | 0 | +-------+ 1 row in set (0.00 sec)
- Related Articles
- How to modify column default value in MySQL?
- How to revert rows to default column value in MySQL?
- Adding a new column with the current time as a default value in MySQL?
- Create MySQL datetime column with default 0000-00-00?
- How can I create a MySQL boolean column and assign value 1 while altering the same column?
- How to check whether column value is NULL or having DEFAULT value in MySQL?
- Set default value to a JSON type column in MySQL?
- How to set NOW() as default value for datetime datatype in MySQL?
- How do I set the default value for a column in MySQL?
- Select data and set value to boolean based on timestamp column in MySQL
- How to set default Field Value in MySQL?
- How to update MySQL column with random value?
- How to set default value to NULL in MySQL?
- How to set MySQL default value NONE?
- Create a Boolean object from Boolean value in Java

Advertisements