All posts
PostgreSQLSeptember 5, 20267 min read

PostgreSQL Data Types Explained for Beginners (Guide)

Confused by PostgreSQL data types? This beginner's guide explains INTEGER, VARCHAR, DATE, and BOOLEAN with simple, copy-paste SQL examples you can run today.

F
Fepiq Team
Fepiq

If you searched for "PostgreSQL data types for beginners," here is the short answer: a data type tells PostgreSQL what kind of value a column can hold, such as a whole number, some text, a date, or a true/false value. Picking the right one keeps your data clean and your database fast. In this guide, you will learn the handful of data types you actually need when you are just starting out, with small examples for each one.

What is a data type, and why does it matter?

A database table is made of columns, and every column stores one kind of value. A data type is the label you give a column that tells PostgreSQL, and everyone reading your table, what kind of value belongs there. For example, an "age" column should only ever hold whole numbers, so you would give it a number data type instead of a text data type.

Choosing the right data type matters for three reasons. First, it stops bad data from getting in, such as accidentally storing the word "twenty" in a column meant for numbers. Second, it saves storage space, because a number is stored more efficiently than the same value written out as text. Third, it lets PostgreSQL sort, filter, and calculate correctly, so dates sort by time and numbers sort by size instead of alphabetically.

The main PostgreSQL data types you will actually use

PostgreSQL supports dozens of data types, but as a beginner you will reach for the same handful again and again. Here is a quick reference table before we go through each one in detail.

Data typeWhat it storesExample value
INTEGERA whole number42
NUMERIC(10,2)A precise decimal number, good for money19.99
VARCHAR(n)Short text with a maximum length'hello'
TEXTText of any length'A long paragraph...'
BOOLEANTrue or falsetrue
DATEA calendar date, no time'2026-09-05'
TIMESTAMPA date and time together'2026-09-05 14:30:00'

Numbers: INTEGER, BIGINT, and NUMERIC

For whole numbers, like a quantity or an age, use INTEGER. If you expect very large numbers, such as a view counter that could pass two billion, use BIGINT instead. For numbers with decimal points where precision matters, like prices, use NUMERIC and tell it how many digits to keep.

sql
CREATE TABLE products (
  id INTEGER,
  stock_count INTEGER,
  price NUMERIC(10, 2)
);

Line by line: CREATE TABLE products starts a new table named products. Each line inside the parentheses defines one column and its data type. id and stock_count are INTEGER because they only ever need whole numbers. price is NUMERIC(10, 2), which means it can store up to 10 digits total, with 2 of them after the decimal point, so it can safely hold a value like 1999.99 without rounding errors.

Why not just use NUMERIC for everything?

You could, but INTEGER is smaller and faster for the database to work with, and it makes your intent clear to anyone reading the table later. Use NUMERIC only when you truly need decimal places, such as money or measurements.

Text: VARCHAR vs TEXT (and why CHAR is rarely used)

VARCHAR(n) stores text up to a maximum length you choose, such as VARCHAR(50) for a username. TEXT stores text of any length, with no limit, which makes it perfect for things like blog posts or comments. In modern PostgreSQL, TEXT and VARCHAR perform almost identically, so many beginners use TEXT everywhere and only add a VARCHAR limit when they specifically want to enforce a maximum length, like a short product code.

sql
CREATE TABLE users (
  id INTEGER,
  username VARCHAR(30),
  bio TEXT
);

Here, username is VARCHAR(30) because usernames should stay short, and PostgreSQL will reject any value longer than 30 characters. bio is TEXT because a user's biography could be one sentence or several paragraphs, and we do not want to guess a maximum length in advance.

There is also a CHAR(n) type, which pads text with extra spaces until it reaches exactly n characters. It is rarely useful for beginners, so you can safely skip it and stick to VARCHAR and TEXT.

Dates and times: DATE, TIME, and TIMESTAMP

Use DATE when you only care about the calendar day, like a birthday. Use TIME when you only care about the clock time, like an opening hour. Use TIMESTAMP when you need both the date and the time together, like the exact moment someone placed an order.

sql
CREATE TABLE orders (
  id INTEGER,
  order_date DATE,
  placed_at TIMESTAMP
);

order_date uses DATE because we only want to know which day the order happened, such as 2026-09-05. placed_at uses TIMESTAMP because it also records the time, such as 2026-09-05 14:30:00, which is useful if you need to know the exact order in which two orders were placed on the same day.

True or false: the BOOLEAN type

A BOOLEAN column can only hold one of two values: true or false. It is the right choice any time you are storing a yes-or-no fact, such as whether an account is active or whether an email has been verified.

sql
CREATE TABLE accounts (
  id INTEGER,
  email VARCHAR(255),
  is_active BOOLEAN
);

is_active is BOOLEAN because an account is either active or it is not, with no middle option. When you insert a row, you would set this column to true or false directly, without quotes, since it is not text.

Bonus types you will see later: JSON and UUID

As you grow past the basics, you will run into two more common types. JSONB stores flexible, structured data, like a small object of settings that does not fit neatly into columns. UUID stores a long, unique random identifier, often used instead of a plain INTEGER for a table's id when you need IDs that are unique across many systems. You do not need either one for your first tables, but it helps to recognize them when you see them.

How to choose the right data type: a quick checklist

  • Storing a whole number, like a count or an age? Use INTEGER.
  • Storing money or anything needing exact decimals? Use NUMERIC(10, 2).
  • Storing short text with a length limit, like a username? Use VARCHAR(n).
  • Storing long or unpredictable text, like a comment or description? Use TEXT.
  • Storing a yes-or-no fact? Use BOOLEAN.
  • Storing a calendar day only? Use DATE.
  • Storing a full date and time? Use TIMESTAMP.

When in doubt, start simple. You can always change a column's data type later with an ALTER TABLE command as your app grows, so do not worry about getting it perfectly right on the first try.

Ready to put these data types to work? Learn how to build your first table step by step.

Read: How to Create a Table in PostgreSQL

Frequently asked questions

What is the most common data type in PostgreSQL?+

For beginners, INTEGER, VARCHAR, TEXT, and TIMESTAMP cover the vast majority of columns you will create. INTEGER handles whole numbers, VARCHAR and TEXT handle text, and TIMESTAMP handles dates with times.

What is the difference between VARCHAR and TEXT in PostgreSQL?+

VARCHAR(n) enforces a maximum length, while TEXT allows text of any length. In PostgreSQL, both perform about the same, so many beginners default to TEXT unless they specifically want to limit how long a value can be.

Should I use SERIAL or INTEGER for an id column?+

SERIAL is a shortcut that creates an INTEGER column which automatically counts up (1, 2, 3, and so on) for every new row. As a beginner, you can use SERIAL for id columns so you do not have to generate the numbers yourself.

Can I change a column's data type after creating the table?+

Yes. You can use an ALTER TABLE command to change a column's data type later, though PostgreSQL will check that your existing data can convert safely to the new type first.

What data type should I use for storing money?+

Use NUMERIC with a fixed number of decimal places, such as NUMERIC(10, 2), instead of a floating-point type. NUMERIC stores exact values, which avoids the small rounding errors that can happen with money calculations.

Want a clear, guided path from your first CREATE TABLE to real queries? We can help you learn PostgreSQL the right way.

Get in touch

Get new posts in your inbox

Occasional, no-fluff notes on shipping modern software — startups, automation, Laravel, Shopify and more. No spam, unsubscribe anytime.

Keep reading

Related posts

All posts

Let's build something

Ready to ship your next product with Fepiq?

Book a free discovery call. We'll listen, ask sharp questions, and send you a proposal within 3 business days.