
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between MySQL TINYINT(2) vs TINYINT(1)?
The number 2 and 1 in TINYINT(2) vs TINYINT(1) indicate the display width. There is no difference between tinyint(1) and tinyint(2) except the width.
If you use tinyint(2) or even tinyint(1), the difference is the same. You can understand the above concept using zerofill option.
- tinyint(1) zerofill
- tinyint(2) zerofill
Let us create a table. The query to create a table is as follows −
mysql> create table tinyIntDemo -> ( -> Number1 tinyint(1) zerofill, -> Number2 tinyint(2) zerofill -> ); Query OK, 0 rows affected (0.62 sec)
Insert record in the table using insert command. The query is as follows −
mysql> insert into tinyIntDemo values(1,1); Query OK, 1 row affected (0.12 sec)
Display records from the table using select command. The query is as follows −
mysql> select *from tinyIntDemo;
The following is the output. Spot the difference between both in the below result −
+---------+---------+ | Number1 | Number2 | +---------+---------+ | 1 | 01 | +---------+---------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- What is difference between Boolean and tinyint(1) in MySQL?
- What is the difference between TINYINT(1) and Boolean in MySQL?
- Is there a difference in using INT(1) vs TINYINT(1) in MySQL?
- What is the difference between BIT and TINYINT in MySQL?
- Does MySQL converts bool to tinyint(1) internally?
- Change tinyint default value to 1 in MySQL?
- MySQL TINYINT type to return <>1 or IS NULL records
- Using Update statement with TINYINT in MySQL?
- Does MySQL Boolean “tinyint(1)” holds values up to 127?
- What is difference between selenium 1 and Selenium 2
- BOOLEAN or TINYINT to store values in MySQL?
- Should I use MySQL enum or tinyint for fields having values 1 and 0?
- Difference between Hadoop 1 and Hadoop 2
- Difference Between COCOMO 1 and COCOMO 2
- How to use tinyint value in Android sqlite?
Advertisements