What is the best Mysql Type to store numeric values

0

I have a table where I store the number of places in numeric values. I would like to know the best mysql type to store these values, taking into consideration that it can be calculated with another field that will receive the same type from another table.

    
asked by anonymous 03.10.2018 / 23:39

1 answer

1
  

Number of places in numeric values

Since there will be no negative number, the field can be of type int unsigned which will store from 0 to 4294967295.

If it's a huge db and you're thinking about space reduction, you can use other integer numeric types:

CREATE TABLE 'inttypes' (                       -- SIGNED ( -X ~ X )    UNSIGNED ( 0 ~ X )
    'tinyint' TINYINT(4) DEFAULT NULL,          -- 127                  255
    'smallint' SMALLINT(6) DEFAULT NULL,        -- 32767                65535
    'mediumint' MEDIUMINT(9) DEFAULT NULL,      -- 8388607              16777215
    'int' INT(11) DEFAULT NULL,                 -- 2147483647           4294967295
    'bigint' BIGINT(20) DEFAULT NULL            -- 9223372036854775807  18446744073709551615
);

Source: MySQL 8.0 Reference Manual - 11.2.1 Integer Types (Exact Value) - INTEGER, INT, SMALLINT , TINYINT, MEDIUMINT, BIGINT

    
03.10.2018 / 23:58