May 2020
Beginner
564 pages
14h 9m
English
The following table takes you through some examples of how to choose data types. It also helps you understand the reasoning behind why you would choose the recommended data type.
| Value(s) or type of data | Type in MySQL |
|
State abbreviations that are always two letters, such as CA, CO – we would use CHAR here instead of VARCHAR because these values will always be the same length. |
CHAR(2) |
|
States names like California or Colorado – we would use VARCHAR here because there is a variable length, and we would set the VARCHAR value to the longest length string, which in this case would be South or North Carolina. |
VARCHAR(14) |
|
Large amounts of text – consider putting TEXT columns in a separate table ... |
Read now
Unlock full access