How To Rename A Field In Sql

3 min read

Renaming a field in SQL is one of those tasks that looks trivial until you try it on the wrong database engine and get a syntax error in return. The truth is that SQL has no single universal "rename column" command — each major database system implements it slightly differently, and older versions of some engines don't support it at all. This guide walks you through the exact syntax for MySQL, PostgreSQL, SQL Server, Oracle, and SQLite, explains how to rename a field only in a query result, and covers the safety checks that prevent a five-second change from turning into an afternoon of broken reports Small thing, real impact..

What "Renaming a Field" Actually Means

In relational databases, the word field is commonly used interchangeably with column. Before writing any statement, be clear about which of these two goals you have:

  1. Permanently renaming a column in the table structure — a schema change (DDL) that affects every query, view, and application that touches that table.
  2. Renaming a column only in the output of a query — a display alias that changes nothing in the database.

Most confusion comes from mixing these up. In practice, the first requires an ALTER TABLE statement (or a system procedure). The second requires nothing more than the AS keyword.

Quick Reference: Rename Column Syntax by Database

Database Statement
MySQL 8.So table. 0+ ALTER TABLE t RENAME COLUMN old TO new;
MySQL 5.7 and earlier ALTER TABLE t CHANGE old new datatype;
PostgreSQL ALTER TABLE t RENAME COLUMN old TO new;
SQL Server EXEC sp_rename 'schema.old', 'new', 'COLUMN';
Oracle ALTER TABLE t RENAME COLUMN old TO new;
SQLite 3.

No fluff here — just what actually works.

Renaming a Column Permanently in Each Database

MySQL

Modern MySQL (8.0 and later) supports the standard syntax:

ALTER TABLE employees
RENAME COLUMN emp_name TO full_name;

On MySQL 5.7 and earlier, RENAME COLUMN does not exist. You must use CHANGE, and the catch is that you have to repeat the entire column definition — data type, nullability, default value, and any AUTO_INCREMENT or comment attributes The details matter here..

ALTER TABLE employees
CHANGE emp_name full_name VARCHAR(100) NOT NULL DEFAULT '';

Always run SHOW CREATE TABLE employees; first and copy the definition exactly.

PostgreSQL

PostgreSQL has supported the clean, standard form for many versions:

ALTER TABLE employees
RENAME COLUMN emp_name TO full_name;

PostgreSQL stores view definitions internally by column position rather than by name, so dependent views keep working after the rename — though their output column names stay the old ones until you rename those too. Functions and stored procedures that reference the old name will break and must be updated And it works..

SQL Server

SQL Server uses a system stored procedure rather than ALTER TABLE:

EXEC sp_rename 'dbo.employees.emp_name', 'full_name', 'COLUMN';

Two warnings matter here. Plus, first, the object name must be qualified with the schema. Second, Microsoft explicitly warns that sp_rename does not automatically update references inside stored procedures, views, functions, or triggers — those objects will still point at the old name and fail at runtime Easy to understand, harder to ignore..

SELECT referencing_entity_name
FROM sys.sql_expression_dependencies
WHERE referenced_entity_name = 'employees';

Oracle

Oracle follows the standard syntax:

ALTER TABLE employees
RENAME COLUMN emp_name TO full_name;

Renaming a column in Oracle invalidates dependent views, procedures, and functions. They are not dropped, but they will not run until recompiled. Oracle typically re

Just Came Out

Just Wrapped Up

Worth the Next Click

We Picked These for You

Thank you for reading about How To Rename A Field In Sql. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home