Array Columns Basics
Create and read array values.
What Is an Array Column?
PostgreSQL supports array columns, which let a single cell hold multiple values of the same type. Instead of storing comma-separated text you get a proper typed list you can query, index, and manipulate with built-in functions.
Arrays can hold integers, text, booleans, dates, or any other PostgreSQL type. The syntax looks like integer[] or text[].
Declaring an Array Column
Add [] after any type name when writing a CREATE TABLE statement to declare an array column. The table below stores a list of tags for each article.
CREATE TABLE articles (
id serial PRIMARY KEY,
title text NOT NULL,
tags text[]
);All lessons in this course
- Array Columns Basics
- Searching Inside Arrays
- UNNEST and Aggregating
- Arrays vs Normalized Tables