Smallint or int to PK / Primary Key / primary key? [closed]

1

In languages such as Java, for example, when processing an int short and comparing with another short int, both are transformed into int. Does the same thing occur in a database like MySQL?

    
asked by anonymous 03.05.2018 / 15:24

1 answer

0

The two types mentioned are integers, what changes is how much each type supports.

smallint: (2 bytes) -32768 to +32767 (with sign) / 0 to 65535 (unsigned)

int: (4 bytes) -2147483648 to +2147483647 (with sign) / 0 to 4294967295 (unsigned)

To know which type to use as a PK, you should look at how much information you will have.

    
03.05.2018 / 16:15