SQL Data Types
SQL stands for Structured Query Language. PostgreSQL , which is an open source relational database management system, uses numeric data types, character data types, and date/time data types, and boolean data types amongst others. The data types listed here are the most common.
Numeric data types can consist of integers and floating points. Integers can have small-ints, integers and serial numbers. Small integers and integers have a range of numbers: small ints have a range of (-32768–32767) and integers have a range of (-214783648, -214783647). A serial numeric data type would mean a number would be auto populated into a column, for instance an id number. Serial is specific to PostgreSQL.
Floating points numbers have three types, float, real and numeric.
Character data types can consist of a char, char(n) and varchar(n). Char refers to a single character. Char(n), where n is a number, Postgres will pad out spaces if the inserted string is less than n. If the string is longer, Postgres will provide an error. Varchar(n), where n is a number, Postgres will only accept up until the nth number of characters in a string. Example, varchar(255) — the number of characters stored in a string cannot exceed 255 characters.
Date/Time datatypes can consist of a timestamp which would be displayed as as ‘YYYY-MM-DD HH:MM:SS’.
Boolean data types are either true or false or unknown. The unknown value is represented by the SQL null value.