MySQL row declarations for ZF?

MySQLMySQLi Database

The ZF stands for ZEROFILL i.e. row declarations for zero fill Let us first create a table. Here, we have set the int field size to be 10 −

mysql> create table DemoTable1332
   -> (
   -> Number int(10) ZEROFILL NOT NULL DEFAULT 0
   -> );
Query OK, 0 rows affected (0.59 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable1332 values();
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable1332 values(1);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1332 values(10);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable1332 values(100);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable1332 values(554646);
Query OK, 1 row affected (0.09 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1332;

This will produce the following output. For numbers with less than 10 field size, the zero fill would get placed, for example 0000000549 −

+------------+
| Number     |
+------------+
| 0000000000 |
| 0000000001 |
| 0000000010 |
| 0000000100 |
| 0000554646 |
+------------+
5 rows in set (0.00 sec)
raja
Published on 05-Nov-2019 06:53:33
Advertisements