- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 usage of ZEROFILL for INT datatype?
On specifying ZEROFILL for a numeric column, MYSQL automatically pads the displayed value of the field with zeros up to the display width specified in the column definition.
For example, we create a table showzerofill and insert the values as follows −
mysql> Create Table showzerofill(Val1 INT(5) ZEROFILL, Val2 INT(5)); Query OK, 0 rows affected (0.09 sec) mysql> Insert into showzerofill(Val1, Val2) values(1,1>,<12,12>,<123,123>,<1234,1234>,<12345,12345>; Query OK, 5 rows affected (0.03 sec) Records: 5 Duplicates: 0 Warnings: 0
Now we can easily understand the effect of ZEROFILL on the values of column Val1.
ZEROFILL padded zeros in the number up to the display width specified in the column definition
mysql> Select * from showzerofill;
+-------+-------+ | Val1 | Val2 | +-------+-------+ | 00001 | 1 | | 00012 | 12 | | 00123 | 123 | | 01234 | 1234 | | 12345 | 12345 | +-------+-------+ 5 rows in set (0.00 sec)
In this sense, we can say that if we want to display the value of a column with a particular width then we can define that column with ZEROFILL.
- What is the usage of zerofill in a MySQL field?
- MySQL BigInt zerofill vs int zerofill?
- What is the benefit of zerofill in MySQL?
- What is the best datatype for currencies in MySQL?
- What is the smallest datatype for one bit in MySQL?
- What is the usage of scrollable cursor for absolute positioning?
- What is the usage of scrollable cursor for current positioning?
- Display Minimum and Maximum values of datatype int in Java
- What is the difference between const int*, const int * const, and int const *?
- For timestamp, which datatype is used in MySQL?