- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 Maximum Value of smallint(6) unsigned in MySQL?
The maximum value of SMALLINT(6) unsigned in MySQL is 65535. The number 6 does not affect the actual range. It can only be used to display width on the command line.
The Minimum Value signed is
-32768
The Maximum Value unsigned is
65535
The Maximum value signed is
32767
Let us understand this with zerofill and create a table using the following query.
mysql> create table smallIntDemo -> ( -> FirstNumber smallint(6) zerofill -> ); Query OK, 0 rows affected (1.95 sec)
Now you can insert records in the table using insert command. Whenever you insert beyond the range 65535, it will not insert in the table, since this is the maximum value. The query is as follows inserting the values less than the maximum range.
mysql> insert into smallIntDemo values(2); Query OK, 1 row affected (0.21 sec) mysql> insert into smallIntDemo values(23); Query OK, 1 row affected (0.21 sec) mysql> insert into smallIntDemo values(234); Query OK, 1 row affected (0.17 sec) mysql> insert into smallIntDemo values(2345); Query OK, 1 row affected (0.15 sec) mysql> insert into smallIntDemo values(23456); Query OK, 1 row affected (0.48 sec)
Now, let us see some records that will not insert in the table since it extends the maximum value.
mysql> insert into smallIntDemo values(234567); ERROR 1264 (22003): Out of range value for column 'FirstNumber' at row 1 mysql> insert into smallIntDemo values(111111); ERROR 1264 (22003): Out of range value for column 'FirstNumber' at row 1
Now you can display all records from the table using select statement. The query is as follows -
mysql> select *from smallIntDemo;
The following is the output displaying the usage of width i.e. number in SMALLINT(6). The width is 6.
+-------------+ | FirstNumber | +-------------+ | 000002 | | 000023 | | 000234 | | 002345 | | 023456 | +-------------+ 5 rows in set (0.00 sec)
- Related Articles
- What is unsigned in MySQL?
- What is the Java equivalent to MySQL's smallint?
- What happens when a negative value is inserted to UNSIGNED column in MySQL?
- How to use smallint value in Android sqlite?
- What is the maximum value of float in Python?
- What is an unsigned char in C++?
- What is the maximum possible value of an integer in C# ?
- What is the maximum possible value of an integer in Python?
- What is the maximum possible value of an integer in Java ?
- What is the maximum length of MySQL VARCHAR column?
- What does “unsigned” in MySQL mean and when to use it?
- Find the Maximum Value in a Column in MySQL
- What is the maximum length of a table name in MySQL?
- Convert varchar to unsigned integer in MySQL
- How to select the maximum value of a column in MySQL?
