- 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 usage of zerofill in a MySQL field?
Zerofill pads the displayed value of the field with zeros up to the display width specified in the column definition. For example, if column is set int(8), therefore the width is 8. If the number is let’s say 4376, then zero will be padded on the left for total width i.e. 8 −
00004376
Let us first create a table −
mysql> create table DemoTable -> ( -> Number int(8) zerofill -> ); Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(1234); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values(678965); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+----------+ | Number | +----------+ | 00000010 | | 00001234 | | 00000001 | | 00678965 | +----------+ 4 rows in set (0.00 sec)
- Related Articles
- What is the usage of ZEROFILL for INT datatype?
- What is the benefit of zerofill in MySQL?
- MySQL BigInt zerofill vs int zerofill?
- What is the usage of “@” symbol in MySQL stored procedure?
- Set custom Auto Increment with ZEROFILL in MySQL
- What is the usage of in operator in JavaScript?
- 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?
- What is the usage of some() method in JavaScript?
- What is the usage of join() method in JavaScript?
- What is the usage of onhashchange event in JavaScript?
- What is the usage of onpageshow event in JavaScript?
- What is the usage of onpagehide event in JavaScript?
- What is the usage of onscroll event in JavaScript?

Advertisements