Standard SQL defines 16 data types, including types for integers and floating-point numbers of various sizes, ASCII or Unicode strings of either fixed or variable sizes, date and time types, and bit types. Nearly every SQL engine extends this with yet more types to accommodate binary data, special types of strings or numbers, and more. Many data types seem a little redundant, and several have aliases that may be different between implementations. Choosing data types for your columns can be surprisingly confusing!
For PostgreSQL, the following chart provides some reasonable choices:
Data being stored
|
Recommended type
|
Notes
|
Fixed-length strings | CHAR | Requires a length. |
Short-to-medium strings | VARCHAR | Requires ... |