
- 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
Should I use MySQL enum or tinyint for fields having values 1 and 0?
For 0 and 1 values, use TINYINT. Let us first create a table −
mysql> create table DemoTable -> ( -> IsMarried tinyint -> ); Query OK, 0 rows affected (0.94 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+-----------+ | IsMarried | +-----------+ | 1 | | 0 | +-----------+ 2 rows in set (0.00 sec)
- Related Articles
- BOOLEAN or TINYINT to store values in MySQL?
- Should I use , , or for SVG files?
- Set conditions for columns with values 0 or 1 in MySQL
- Does MySQL Boolean “tinyint(1)” holds values up to 127?
- MySQL TINYINT type to return 1 or IS NULL records
- Which datatype should I use for flag in MySQL?
- MySQL ENUM column match for quoted values
- Set ENUM in MySQL for column values
- Set custom messages for enum values in MySQL
- What is the difference between MySQL TINYINT(2) vs TINYINT(1)?
- When should I use MySQL compressed protocol?
- What is difference between Boolean and tinyint(1) in MySQL?
- Which one should I use? The datetime or timestamp data type in MySQL?
- How can I get enum possible values in a MySQL database?
- Change tinyint default value to 1 in MySQL?

Advertisements