6 digit numeric column in MySQL

Let's say I want to save a six-digit column for a table in my database - is it possible to indicate this at the database level in MySQL?

+4
source share
2 answers

Use the data type MEDIUMINT or, more precisely, MEDIUMINT (6):

The average integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.

Since you are going to use it as an identifier column, you will most likely want to make it UNSIGNED NOT NULL auto_increment .

+3
source

You can set the initial value of the AUTO_INCREMENT column so that it starts at 100000:

 CREATE TABLE tbl ( id INT NOT NULL AUTO_INCREMENT, ... ); ALTER TABLE tbl AUTO_INCREMENT = 100000; 

So the first number to be inserted will be 100000, the next will be 100001, etc.

If this is not what you need, you need to be more specific ...

+1
source

Source: https://habr.com/ru/post/1310330/


All Articles