Add Column

Learn how to use ALTER TABLE ADD COLUMN to add one or more columns to an existing PostgreSQL table.

4 min read · Last updated: March 2026 · Back to overview

Quick Answer

Use ALTER TABLE table_name ADD COLUMN column_name data_type constraint to add a new column. New columns are appended at the end of the table. Add multiple columns by chaining ADD COLUMN clauses separated by commas. Adding a NOT NULL column to a non-empty table requires a default value or a separate backfill step.

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

The ALTER TABLE ... ADD COLUMN statement extends an existing PostgreSQL table with one or more new columns. New columns are always appended at the end of the column list — PostgreSQL has no option to insert a column at a specific position. Adding a nullable column (or a column with a constant default in PostgreSQL 11+) is a metadata-only operation that completes instantly even on very large tables.

ADD COLUMN syntax

ALTER TABLE table_name
  ADD COLUMN column_name data_type [constraint];

To add multiple columns in one statement:

ALTER TABLE table_name
  ADD COLUMN col1 data_type constraint,
  ADD COLUMN col2 data_type constraint,
  ...;

ADD COLUMN examples

Create a sample table:

CREATE TABLE customers (
  id            SERIAL PRIMARY KEY,
  customer_name VARCHAR(255) NOT NULL
);

Add a single nullable column:

ALTER TABLE customers ADD COLUMN phone VARCHAR(25);

Add multiple columns at once:

ALTER TABLE customers
  ADD COLUMN fax   VARCHAR(25),
  ADD COLUMN email VARCHAR(400);

Verify the structure:

d customers

          Table "public.customers"
     Column      |          Type          | Nullable
-----------------+------------------------+----------
 id              | integer                | not null
 customer_name   | character varying(255) | not null
 phone           | character varying(25)  |
 fax             | character varying(25)  |
 email           | character varying(400) |

Adding a NOT NULL column to a table that already has data:

-- This fails if the table has rows:
ALTER TABLE customers ADD COLUMN contact_name VARCHAR(255) NOT NULL;
-- ERROR: column "contact_name" of relation "customers" contains null values

-- Correct approach:
-- Step 1: add without NOT NULL
ALTER TABLE customers ADD COLUMN contact_name VARCHAR(255);

-- Step 2: populate the new column
UPDATE customers SET contact_name = 'John Doe'   WHERE id = 1;
UPDATE customers SET contact_name = 'Mary Doe'   WHERE id = 2;
UPDATE customers SET contact_name = 'Lily Bush'  WHERE id = 3;

-- Step 3: enforce NOT NULL
ALTER TABLE customers ALTER COLUMN contact_name SET NOT NULL;

ADD COLUMN tips

  • Adding a nullable column to a large table is safe and instant in PostgreSQL — it does not rewrite the table or block reads.
  • Adding a column with a constant (non-volatile) default is also metadata-only in PostgreSQL 11+ and does not require a table rewrite.
  • Never add a NOT NULL column directly to a non-empty table without a default — follow the three-step add, backfill, constrain pattern above.
  • Use a single ALTER TABLE with multiple ADD COLUMN clauses to minimize the number of locks acquired.

Reference: PostgreSQL documentation — ALTER TABLE.

Continue in Managing Tables: Drop Column.

Related in this section: PostgreSQL Data Types · Create Table · Select Into

Frequently Asked Questions

Can I specify the position of a new column in PostgreSQL?

No. PostgreSQL always appends new columns at the end of the table. If column order matters for display, control it in your SELECT statements using explicit column lists.

Why does adding a NOT NULL column to an existing table fail?

When you add a column, existing rows receive NULL for the new column. If you add a NOT NULL constraint at the same time, PostgreSQL checks all existing rows and fails because they are NULL. The solution is to add the column without NOT NULL, populate it with an UPDATE, then apply SET NOT NULL.

Is adding a column safe on a large production table?

Adding a nullable column (with no default, or with a constant default in PostgreSQL 11+) is a metadata-only change that completes instantly without rewriting the table. It does take a brief ACCESS EXCLUSIVE lock. Adding a column with a volatile default (such as now()) or a function call still rewrites the table in older versions.

How do I add multiple columns to a table at once?

Chain multiple ADD COLUMN clauses in one ALTER TABLE statement: ALTER TABLE t ADD COLUMN col1 TEXT, ADD COLUMN col2 INT; This is more efficient than separate statements because it requires only one lock acquisition.

Can I add a column with a default value that fills existing rows?

Yes. In PostgreSQL 11+, adding a column with a constant default value is a fast metadata-only operation and existing rows immediately see the default value without a table rewrite. For volatile defaults (expressions like now()), you must add the column and then UPDATE existing rows separately.