SQL Data Types

Last updated: August 26, 2026.

A column’s data type defines the values it can store and the operations a database can perform efficiently. Exact names and limits vary by database engine.

CategoryCommon SQL typesUse
Exact numbersSMALLINT, INTEGER, BIGINT, DECIMAL(p,s)Counts, identifiers, and exact monetary values
Approximate numbersREAL, DOUBLE PRECISIONScientific measurements where approximation is acceptable
TextCHAR(n), VARCHAR(n), TEXTNames, codes, and free-form text
Date and timeDATE, TIME, TIMESTAMPCalendar and event values
LogicalBOOLEAN or engine-specific equivalentTrue/false state
Binary and structuredBINARY, BLOB, JSON, XMLFiles or structured documents

Example table

CREATE TABLE orders (
    order_id BIGINT PRIMARY KEY,
    customer_name VARCHAR(200) NOT NULL,
    order_total DECIMAL(12, 2) NOT NULL,
    placed_at TIMESTAMP NOT NULL,
    is_paid BOOLEAN NOT NULL
);

Choose the narrowest type that represents the domain without losing valid values. Use exact decimal types for money and check your database’s documentation for ranges, time-zone behavior, and engine-specific types.

admin

admin

Leave a Reply

Your email address will not be published.