hi am new to sql can anyone help me with it.
I want to create a field example code date_type int auto increment with min size 9 that is that number should be 000000001,000000002...000000010...开发者_如何学Python.
Use ZEROFILL. Here is an example:
CREATE TABLE zerofill_test (f1 INT(4) ZEROFILL,f2 INT(4));
INSERT INTO zerofill_test VALUES ( 1, 1 ), (10000, 10000);
Here f1 is defined with 'ZEROFILL' of 'int' type and f2 is simple int
.
When data is selected with SELECT
command it shows you the desired result.
SELECT * FROM zerofill_test;
+-------+-------+
| h | m |
+-------+-------+
| 0001 | 1 |
| 10000 | 10000 |
+-------+-------+
For you purpose, the size of int field should be 9 i.e. `date_type int(9) ZEROFILL'
精彩评论