SQLMentor // glossary

Data Type

A data type defines what kind of value a column can hold — a number, a piece of text, a date, a boolean — and constrains how the database stores, compares, sorts, and validates that column's values.

Choosing the right data type isn't cosmetic: it affects storage size, index efficiency, and which comparisons are even legal. Storing a date as text, for example, loses correct chronological sorting and date arithmetic that a real DATE type provides for free.

Every mainstream database has its own type names and quirks — Oracle's VARCHAR2 vs PostgreSQL's VARCHAR/TEXT, Oracle's all-purpose NUMBER vs Postgres's distinct INTEGER/NUMERIC/REAL family — so porting schemas between databases usually means re-mapping types, not copying them directly.

Example

CREATE TABLE employees (
  employee_id INT PRIMARY KEY,
  salary      NUMERIC(8,2),
  hire_date   DATE,
  is_active   BOOLEAN
);