Data Types

Just like any other programming language, databases have predefined data types for storing information.

There are many data types in a database, but let’s cover the most basic ones for now.


Numeric Types

  1. integer: The most basic whole number type. It can store numbers from approximately -2.1 billion to 2.1 billion.
  2. bigint: Used when you need to store very large integers. It can store numbers from approximately -9.22 quintillion to 9.22 quintillion.

Character (String) Types

  1. text: The most recommended character type in PostgreSQL. It can store very long sentences without a character limit and offers excellent performance.
  2. varchar(n): Used when you want to limit the maximum number of characters. For example, varchar(10) allows a maximum of 10 characters.

Date and Time Types

  1. date: Stores only the date. (e.g., 2026-02-08)
  2. timestamp: Stores both the date and time. (e.g., 2026-02-08 12:05:44)

Boolean Type

  1. boolean: Can store only two values: true or false. (e.g., ‘Payment completed?’, ‘Account deactivated?’)

These seven types are used very frequently, so it’s a good idea to take a moment to memorize them.

Now, let’s try creating a table using these data types.