Smallint or int to PK / Primary Key / Primary key?

Asked

Viewed 155 times

1

In languages such as Java, for example, when processing a short int and comparing it with another short int, both are transformed into int. The same occurs in databases like Mysql?

  • What is the relevance? And I don’t know if this happens with Java, have any source? It has consequence?

1 answer

0

The two types cited are integer, what changes is how much each type supports.

smallint: (2 bytes) -32768 to +32767 (with signal) / 0 to 65535 (without signal)

int: (4 bytes) -2147483648 to +2147483647 (with signal) / 0 to 4294967295 (without signal)

To know which type to use as PK, must be analyzed the amount of information you will have.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.