Rename Column

Learn how to rename a column in PostgreSQL using ALTER TABLE ... RENAME COLUMN, including how dependent objects like views and foreign keys are automatically updated.

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

Quick Answer

Use ALTER TABLE table_name RENAME COLUMN old_name TO new_name; to rename a column in PostgreSQL. The COLUMN keyword is optional. PostgreSQL automatically updates dependent objects such as views, triggers, and foreign key constraints to reference the new column name.

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

Renaming a column in PostgreSQL is done with the ALTER TABLE ... RENAME COLUMN statement. Unlike some schema changes, this operation is safe for dependent objects: PostgreSQL automatically cascades the rename to views, foreign key constraints, triggers, and stored procedures that reference the column.

Basic syntax

The full syntax to rename a column is:

ALTER TABLE table_name
RENAME COLUMN column_name TO new_column_name;

The COLUMN keyword is optional, so this shorter form also works:

ALTER TABLE table_name
RENAME column_name TO new_column_name;

To rename multiple columns, run separate statements — there is no single-statement shortcut for multiple renames:

ALTER TABLE customers RENAME COLUMN name TO customer_name;
ALTER TABLE customers RENAME COLUMN phone TO contact_phone;

If the column does not exist, PostgreSQL raises an error. There is no IF EXISTS option for the RENAME COLUMN clause.

Practical examples

First, set up sample tables including a view that references a column you will rename:

CREATE TABLE customer_groups (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL
);

CREATE TABLE customers (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL,
  phone VARCHAR NOT NULL,
  email VARCHAR,
  group_id INT,
  FOREIGN KEY (group_id) REFERENCES customer_groups (id)
);

CREATE VIEW customer_data AS
SELECT c.id, c.name, g.name AS customer_group
FROM customers c
INNER JOIN customer_groups g ON g.id = c.group_id;

Rename the email column of the customers table:

ALTER TABLE customers RENAME COLUMN email TO contact_email;

Now rename the name column in customer_groups, which is referenced by the customer_data view:

ALTER TABLE customer_groups RENAME COLUMN name TO group_name;

PostgreSQL automatically updates the view definition. Inspecting the view confirms the cascade:

d+ customer_data

-- Output:
-- View definition:
-- SELECT c.id, c.name, g.group_name AS customer_group
-- FROM customers c
-- JOIN customer_groups g ON g.id = c.group_id;

Production tips

  • Column renames are metadata-only operations in PostgreSQL — they do not rewrite table data and are very fast even on large tables.
  • PostgreSQL acquires an ACCESS EXCLUSIVE lock during the rename, which blocks reads and writes briefly. Run renames during low-traffic windows for busy tables.
  • Update application code, ORM models, and query strings before or immediately after the rename to avoid runtime errors.
  • Use pg_depend or d+ view_name to audit dependent objects before and after renaming to confirm cascade behaviour.
  • In migration frameworks, pair the rename with a corresponding rollback that renames the column back to the original name.

Continue in Managing Tables: Drop Table.

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

Frequently Asked Questions

Does renaming a column in PostgreSQL update dependent views automatically?

Yes. PostgreSQL automatically updates views, foreign key constraints, triggers, and stored procedures that reference the renamed column. You do not need to drop and recreate them manually.

Is there an IF EXISTS option for RENAME COLUMN?

No. PostgreSQL does not support IF EXISTS for the RENAME COLUMN clause. If the column does not exist, the statement raises an error. You can check for the column in pg_attribute before running the rename if you need conditional logic.

Can I rename multiple columns in one ALTER TABLE statement?

No. Each RENAME COLUMN clause is a separate ALTER TABLE statement. Run one statement per column you want to rename.

Will renaming a column lock the table and block queries?

Yes, briefly. ALTER TABLE RENAME COLUMN acquires an ACCESS EXCLUSIVE lock, which blocks concurrent reads and writes for the duration of the operation. The operation itself is fast (metadata-only), so the lock is held for a very short time.

Does RENAME COLUMN rewrite the table data on disk?

No. Renaming a column is a metadata-only change stored in the system catalog. No rows are rewritten, making it safe and fast regardless of table size.