This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

MEDIUMINT

Sintassi

MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]

Spiegazione

Un intero di dimensioni medie. Se con segno, i valori vanno da -8388608 a 8388607. Se senza segno, vanno da 0 a 16777215.

ZEROFILL riempe il valore con degli zeri iniziali fino a raggiungere M cifre, e trasforma il valore in UNSIGNED (anche se UNSIGNED non è specificato).

Esempi

MariaDB [test]> create table mediumints (a MEDIUMINT,b MEDIUMINT UNSIGNED,c MEDIUMINT ZEROFILL);
Query OK, 0 rows affected (0.30 sec)

MariaDB [test]> describe mediumints;
+-------+--------------------------------+------+-----+---------+-------+
| Field | Type                           | Null | Key | Default | Extra |
+-------+--------------------------------+------+-----+---------+-------+
| a     | mediumint(9)                   | YES  |     | NULL    |       |
| b     | mediumint(8) unsigned          | YES  |     | NULL    |       |
| c     | mediumint(8) unsigned zerofill | YES  |     | NULL    |       |
+-------+--------------------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

MariaDB [test]> INSERT INTO mediumints VALUES (-10,-10,-10);
ERROR 1264 (22003): Out of range value for column 'b' at row 1

MariaDB [test]> INSERT INTO mediumints VALUES (-10,10,-10);
ERROR 1264 (22003): Out of range value for column 'c' at row 1

MariaDB [test]> INSERT INTO mediumints VALUES (-10,10,10);
Query OK, 1 row affected (0.14 sec)

MariaDB [test]> INSERT INTO mediumints VALUES (8388608,8388608,8388608);
ERROR 1264 (22003): Out of range value for column 'a' at row 1

MariaDB [test]> INSERT INTO mediumints VALUES (8388607,8388608,8388608);
Query OK, 1 row affected (0.13 sec)

MariaDB [test]> select * from mediumints;
+---------+---------+----------+
| a       | b       | c        |
+---------+---------+----------+
|     -10 |      10 | 00000010 |
| 8388607 | 8388608 | 08388608 |
+---------+---------+----------+
2 rows in set (0.00 sec)

MariaDB [test]> 

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.