- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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)
Advertisements
To Continue Learning Please Login
Login with Google