dev.rean.me
database

Common SQL Data Types in Database

Simple guide to understand common SQL Data Types in Database like Numeric, String, Date, Binary, and Boolean with practical tips. Learn differences between DBMS systems.

2026-08-23 ยท 4 min read

Share:

Hello my friend! Today we learn about SQL Data Types in Database!

When we create table in database, every column must have a Data Type. Data type tell database what kind of value can save into that column. Is it number, text, date, or true/false boolean value?

SQL Data Types Overview by Kanak InfoSystems

๐Ÿ’ก Important Note: Different DBMS (Database Management System) like MySQL, PostgreSQL, MS SQL Server, or Oracle have small differences in data type names, but basic concept is very similar!


1. ๐Ÿ”ข Numeric Data Types (Numbers)

Numeric data types are used to store numbers like age, quantity, price, or salary.

A. Exact Numeric Data Types

Store numbers with exact precision (no rounding error):

  • TINYINT: Very small integer (0 to 255).
  • SMALLINT: Small integer.
  • INT / INTEGER: Standard integer number for ID, age, or quantity.
  • BIGINT: Large integer number for huge counter or big ID.
  • DECIMAL(p, s) / NUMERIC: Exact decimal number for price or money.

B. Approximate Numeric Data Types

Store numbers with floating point precision:

  • FLOAT / REAL / DOUBLE: Store decimal number with floating point.

๐Ÿ’ก Tip for Money & Price: For salary or product price, ALWAYS use DECIMAL(10, 2) or NUMERIC! Do NOT use FLOAT for money because FLOAT can cause small decimal rounding calculations error!


2. ๐Ÿ”ค Character & String Data Types (Text)

String data types are used to store names, descriptions, emails, or phone numbers.

A. Regular Character Data Types

  • CHAR(n): Fixed length text. If you define CHAR(10) and type "Sok", it still use 10 spaces.
  • VARCHAR(n): Variable length text. If you define VARCHAR(50) and type "Sok", it only use 3 spaces!

B. Unicode Character Data Types

  • NCHAR(n): Fixed length Unicode text.
  • NVARCHAR(n): Variable length Unicode text. Used for multi-language text like Khmer Unicode characters (Khmer: แž—แžถแžŸแžถแžแŸ’แž˜แŸ‚แžš).

๐Ÿ’ก Tip for Text & Khmer Font: Use VARCHAR(50) for normal English text like email or username to save disk space. In MS SQL Server, always use NVARCHAR for Khmer language text so characters don't turn into question marks ????!


3. ๐Ÿ“… Date & Time Data Types

Used to store date of birth, order created time, or event schedules.

  • DATE: Store date only (YYYY-MM-DD, example: 2026-08-24).
  • TIME: Store time only (HH:MM:SS).
  • DATETIME / TIMESTAMP: Store both date and exact time (2026-08-24 14:30:00).

๐Ÿ’ก Tip for Date: Use DATE column for user birthday. Use TIMESTAMP or DATETIME for order created time so you know exact minute and second order was placed!


4. ๐Ÿ’พ Binary Data Types

Used to store binary data like images, files, or encrypted hash bytes.

  • BINARY / VARBINARY: Store binary bytes data.
  • BLOB (Binary Large Object): Store large binary files like images, audio, or PDF documents.

๐Ÿ’ก Tip for Images & Files: Storing big image files directly into database BLOB column will make database size super big and backup slow! Best practice in real app is save image file to cloud storage (like S3 or CDN), and only save image URL string (VARCHAR) in database table!


5. โš™๏ธ Miscellaneous Data Types

Special data types for specific use cases:

  • BIT / BOOLEAN: Store 1 or 0 (TRUE or FALSE) for status like is_active or is_paid.
  • JSON: Store structured JSON objects directly inside column (available in PostgreSQL & MySQL).
  • XML / CLOB / CURSOR / TABLE: Special types for large text document or stored procedure logic.

๐Ÿ’ก Tip for Boolean Status: For user status like active or inactive, use BOOLEAN or BIT(1)! It is fast and clean.


๐Ÿ“Š Data Types Reference by DBMS System

Here are reference charts for data types in different popular database engines:

๐Ÿ”น PL/SQL (Oracle) Data Types

PLSQL Data Types by Technicalblog

๐Ÿ”น MS SQL Server Data Types

SQL Server Data Type by GeeksforGeeks

๐Ÿ”น PostgreSQL Data Types

PostgreSQL Data Type by SQL Tutorials


Happy learning database my friend! If you have any question about SQL data types, leave comment below! ๐Ÿš€