Types MySQL Types MySQL (par défaut) Taille (en octet) Valeur min Valeur max JAVA
TINYINT tinyint(4) 1 -128 127 byte : (1 octet ) entiers compris entre -128 et +127 (-2^7 et 2^7-1)
TINYINT (unsigned) tinyint(3) UNSIGNED 1 0 255
SMALLINT smallint(6) 2 -32.768 32.767 short : (2 octets ) entiers compris entre -32768 et +32767 (-2^15 et 2^15-1)
SMALLINT (unsigned) smallint(5) UNSIGNED 2 0 65.535
MEDIUMINT mediumint(9) 3 -8.388.608 8.388.607
MEDIUMINT (unsigned) mediumint(8) UNSIGNED 3 0 16.777.215
INT int(11) 4 -2.147.483.648 2.147.483.647 int : (4 octets ) entiers compris entre -2147483648 et +2147483647 (-2^31 et 2^31-1)
INT (unsigned) int(10) UNSIGNED 4 0 4.294.967.295
BIGINT bigint(20) 8 -9.223.372.036.854.775.808 9.223.372.036.854.775.807 long : (8 octets ) entiers compris entre -9223372036854775808 et +9223372036854775807 (-2^63 et 2^63-1)
BIGINT (unsigned) bigint(20) UNSIGNED) 8 0 18.446.744.073.709.551.615
/**
 * les TYPES
 * https://sql.sh/416-limites-types-donnees-sgbd
Types           Taille (en octet                Valeur min                  Valeur max  JAVA
TINYINT                     1                         -128                         127  byte :  (1 octet ) entiers compris entre -128 et +127 (-2^7 et 2^7-1)
TINYINT (unsigned)          1                            0                         255  
SMALLINT / INT2             2                      -32.768                       2.767  short : (2 octets) entiers compris entre -32768 et +32767 (-2^15 et 2^15-1)
SMALLINT / INT2 (unsigned)  2                            0                      65.535  
MEDIUMINT                   3                   -8.388.608                   8.388.607  
MEDIUMINT (unsigned)        3                            0                  16.777.215  
INT / INTEGER / INT4            4           -2.147.483.648               2.147.483.647  int :   (4 octets) entiers compris entre -2147483648 et +2147483647 (-2^31 et 2^31-1)
INT / INTEGER / INT4 (unsigned) 4                        0               4.294.967.295  
BIGINT / INT8               8   -9.223.372.036.854.775.808   9.223.372.036.854.775.807  long :  (8 octets) entiers compris entre -9223372036854775808 et +9223372036854775807 (-2^63 et 2^63-1)
BIGINT / INT8 (unsigned)    8                            0  18.446.744.073.709.551.615
 * https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
Type    Storage (Bytes)     Minimum Value Signed    Minimum Value Unsigned  Maximum Value Signed    Maximum Value Unsigned
TINYINT       1                        -128                      0                     127                     255
SMALLINT      2                      -32768                      0                   32767                   65535
MEDIUMINT     3                    -8388608                      0                 8388607                16777215
INT           4                 -2147483648                      0              2147483647              4294967295
BIGINT        8                       -2^63                      0                  2^63-1                  2^64-1
 
ALTER TABLE `test_type` 

ADD `tinyint_basic` TINYINT NOT NULL,                 -- tinyint(4)
ADD `tinyint_unsigned` TINYINT UNSIGNED NOT NULL,     -- tinyint(3) UNSIGNED

ADD `smallint_basic` SMALLINT NOT NULL,               -- smallint(6)
ADD `smallint_unsigned` SMALLINT UNSIGNED NOT NULL,   -- smallint(5) UNSIGNED

ADD `mediumint_basic` MEDIUMINT NOT NULL,             -- mediumint(9)
ADD `mediumint_unsigned` MEDIUMINT UNSIGNED NOT NULL, -- mediumint(8) UNSIGNED

ADD `int_basic` INT NOT NULL,                         -- int(11)
ADD `int_unsigned` INT UNSIGNED NOT NULL,             -- int(10) UNSIGNED

ADD `bigint_basic` BIGINT NOT NULL,                   -- bigint(20)
ADD `bigint_unsigned` BIGINT UNSIGNED NOT NULL        -- bigint(20) UNSIGNED

;

*/

Valeurs max des données numériques en SQL

MySQL :

JAVA :

developpez.com :

  • Tableau de relations : tableau des correspondances entre les types SQL définis dans java.sql.Types, les méthodes de ResultSet et les types Java