Choosing Data Types
Cheat sheet · https://pcornel.dk/topic.php?topic=6168
Answer
Data types define what a column can hold: integers, numeric/decimal, text, dates/timestamps with or without time zone, booleans, UUIDs, JSON.
Remember
Money in DECIMAL/NUMERIC, not float. Timestamps with time zone (store UTC). Sizes that fit growth (bigint for IDs). Avoid storing numbers or dates as text.
First checks
\d <table>— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
value → type validation → storage → comparison/sorting
Where it usually breaks
utf8 in older MySQL is limited to three bytes and cannot store emoji; use utf8mb4.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6168