
- 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
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.
- Related Articles
- MySQL BigInt zerofill vs int zerofill?
- What is the usage of zerofill in a MySQL field?
- What is the benefit of zerofill in MySQL?
- What is the best datatype for currencies in MySQL?
- Display Minimum and Maximum values of datatype int in Java
- 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?
- Test whether int datatype of different sizes are not subdtypes of each other in Python
- What is the difference between const int*, const int * const, and int const *?
- For timestamp, which datatype is used in MySQL?
- What is the purpose and usage of “FOR UPDATE OF” clause in a COBOL-DB2 program
- What is the usage of every() method in JavaScript?
- What is the usage of fill() method in JavaScript?
- What is the usage of copyWithin() method in JavaScript?

Advertisements