Numeric Types
Before you create a table, you should know what
kind of data you wish to store in the table. Beyond obvious decisions
about whether your data is character-based or numeric, you should
know the approximate size of the data to be stored. If it is a
numeric field, what is its maximum possible value? What is its
minimum possible value? Could that change in the future? If the
minimum is always positive or zero, you should consider an unsigned
type. You should always choose the smallest numeric type that can
support your largest conceivable value. If, for example, you have a
field that represents the population of a state, use an unsigned
INT field. No state can have a negative
population. Furthermore, an unsigned INT field is
certainly large enough to represent a state’s
population, unless that population grows to be roughly the current
population of the entire Earth.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access