How to Rename a Column in SQL
By Rohan Vats
Updated on Sep 22, 2025 | 13 min read | 49.05K+ views
Share:
For working professionals
For fresh graduates
More
By Rohan Vats
Updated on Sep 22, 2025 | 13 min read | 49.05K+ views
Share:
Table of Contents
Renaming a column in SQL is a common task when managing databases. Whether you need clearer names, updated naming conventions, or to correct errors, knowing how to rename a column is essential. This guide will show you how to rename a column in SQL across different database systems.
In this blog, you will learn step-by-step methods to rename columns in MySQL, SQL Server, Oracle, and PostgreSQL. You will see code examples, best practices, and how to avoid common mistakes while renaming columns.
Want to strengthen your SQL and data skills? Explore our Online Data Science Courses and take the next step in your tech career!
When you need to change a column's name, you first have to ask: is this change for a single query, or is it a permanent change to the database structure? SQL provides two different methods to handle these scenarios.
Take your expertise beyond SQL and dive into cutting-edge fields like data science, AI, and generative AI with these top university-backed programs:
upGrad’s Exclusive Software and Tech Webinar for you –
SAAS Business – What is So Different?
Software Development Courses to upskill
Explore Software Development Courses for Career Progression
Here is a quick comparison of the two methods:
Feature | Temporary Renaming (Alias) | Permanent Renaming |
Purpose | Improve readability of query results. | Update the database structure. |
Command | SELECT ... AS ... | ALTER TABLE ... |
Permanence | Lasts only for one query. | Permanent until changed again. |
Use Case | Creating reports, simplifying complex queries. | Correcting typos, standardizing naming. |
The most frequent way you will rename a column is temporarily within a SELECT statement. This is called aliasing. An alias is a temporary, alternative name for a column or table that exists only for the duration of the query. It is a simple yet powerful tool for improving clarity.
The primary reasons to use an alias are:
The syntax for creating a column alias is straightforward:
SQL
SELECT original_column_name AS new_column_name
FROM table_name;
In most SQL dialects, including PostgreSQL and Oracle, the AS keyword is optional, so you can also write:
SQL
SELECT original_column_name new_column_name
FROM table_name;
Let's assume we have an employees table with the following structure and data:
emp_id | first_name | last_name | hire_dt | monthly_salary |
101 | Maria | Jones | 2023-05-10 | 5000 |
102 | David | Smith | 2022-11-20 | 6500 |
Example 1: Basic Column Renaming
Let's make the column names in our query result more readable.
SQL
SELECT
emp_id AS "Employee ID",
first_name AS "First Name",
last_name AS "Last Name"
FROM
employees;
Result:
Employee ID |
First Name |
Last Name |
101 | Maria | Jones |
102 | David | Smith |
Note: We use double quotes to create aliases with spaces.
Example 2: Renaming a Calculated Column
Aliases are essential for giving a name to a column that is generated from a calculation.
SQL
SELECT
first_name,
monthly_salary * 12 AS "Annual Salary"
FROM
employees;
Result:
first_name |
Annual Salary |
Maria | 60000 |
David | 78000 |
Without the alias, the second column would have a generic or system-generated name like column, which is not helpful.
Also Read: SQL for Data Science: Functions, Queries, and Best Practices
When you need to make a lasting change to your database structure, you will use the ALTER TABLE statement. This command modifies the definition of a table, and one of its functions is to rename columns.
The exact syntax for how to rename a column in SQL permanently can differ between database management systems (DBMS). Below, we will cover the specific commands for four of the most popular systems: MySQL, PostgreSQL, SQL Server, and Oracle.
MySQL provides two ways to rename a column: RENAME COLUMN and CHANGE.
Method 1: Using RENAME COLUMN
This is the preferred and more direct method. It only changes the name of the column.
Syntax:
SQL
ALTER TABLE table_name
RENAME COLUMN old_column_name TO new_column_name;
Example:
Let's create a sample products table.
SQL
CREATE TABLE products (
prod_id INT PRIMARY KEY,
prod_name VARCHAR(100),
price_usd DECIMAL(10, 2)
);
Now, let's rename the price_usd column to price.
SQL
ALTER TABLE products
RENAME COLUMN price_usd TO price;
The column is now permanently renamed. Any new query must use price.
Method 2: Using CHANGE
The CHANGE keyword can also rename a column, but it is more powerful and requires you to restate the column's data type and other attributes.
Syntax:
SQL
ALTER TABLE table_name
CHANGE old_column_name new_column_name column_definition;
Example:
Let's change prod_name to product_name and keep its data type.
SQL
ALTER TABLE products
CHANGE prod_name product_name VARCHAR(100);
You must provide the data type (VARCHAR(100)) again. Forgetting or changing this can lead to data loss, so RENAME COLUMN is generally safer for simple renaming tasks.
Also Read: Difference Between VARCHAR and VARCHAR2
PostgreSQL follows the SQL standard for renaming columns, making its syntax very clean and intuitive.
Syntax:
SQL
ALTER TABLE table_name
RENAME COLUMN old_column_name TO new_column_name;
Example:
Let's create a customers table and then rename a column.
SQL
CREATE TABLE customers (
cust_id SERIAL PRIMARY KEY,
fname VARCHAR(50),
email_address VARCHAR(100)
);
Now, let's rename the fname column to first_name.
SQL
ALTER TABLE customers
RENAME COLUMN fname TO first_name;
The command is simple and directly communicates your intent, which is a key part of how to rename a column in SQL effectively.
Also Read: MongoDB vs PostgreSQL: Key Differences, Similarities, and More
Let’s check how to rename a column in SQL Server.
SQL Server uses a system stored procedure called sp_rename to rename database objects, including columns.
Syntax:
SQL
EXEC sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN';
Example:
Let's create an orders table and rename a column.
SQL
CREATE TABLE orders (
order_id INT PRIMARY KEY,
order_dt DATE,
shipping_addr VARCHAR(255)
);
Now, let's rename order_dt to order_date.
SQL
EXEC sp_rename 'orders.order_dt', 'order_date', 'COLUMN';
The first parameter is the object to be renamed, formatted as 'TableName.OldColumnName'. The second is the new name, and the third parameter specifies that you are renaming a COLUMN.
Also Read: Mastering SQL Server Management Studio (SSMS): A Comprehensive Guide
After knowing how to rename a column in SQL Server, now explore how to rename for Oracle.
Oracle also follows the standard SQL syntax for renaming columns, similar to PostgreSQL.
Syntax:
SQL
ALTER TABLE table_name
RENAME COLUMN old_column_name TO new_column_name;
Example:
Let's create an inventory table and then perform a rename.
SQL
CREATE TABLE inventory (
item_id NUMBER PRIMARY KEY,
item_desc VARCHAR2(200),
qty_on_hand NUMBER
);
Now, let's rename item_desc to item_description.
SQL
ALTER TABLE inventory
RENAME COLUMN item_desc TO item_description;
Summary Table for Quick Reference:
Here is a table summarizing how to rename a column in SQL across the different systems-
Database System | Command |
MySQL | ALTER TABLE ... RENAME COLUMN ... TO ...; or ALTER TABLE ... CHANGE ... ...; |
PostgreSQL | ALTER TABLE ... RENAME COLUMN ... TO ...; |
SQL Server | EXEC sp_rename 'table.old_col', 'new_col', 'COLUMN'; |
Oracle | ALTER TABLE ... RENAME COLUMN ... TO ...; |
Subscribe to upGrad's Newsletter
Join thousands of learners who receive useful tips
Permanently renaming a column is a significant change to your database schema and carries risks. It is not just about changing a name; it can have a ripple effect across your entire system.
The column you are renaming might be used by other database objects or by your application code. Changing the name will break these dependencies.
Also Read: SQL Jobs for Freshers: Salary, Career Growth & Opportunities
To mitigate these risks, always follow a careful process:
Learning how to rename a column in SQL is more than just memorizing a command. It is about understanding the difference between temporary and permanent changes and managing the impact of those changes safely. With the commands and best practices outlined above, you are now prepared to manage your database schema with confidence.
Discover our top Software Engineering courses and find the perfect program to advance your skills and career!
Unlock your potential with our free Software Development courses and start building skills for a thriving tech career!
Master essential Software Development skills in demand and stay ahead in the dynamic tech industry!
Dive into our popular articles on Software and stay informed about the latest trends and innovations in the field!
Discover popular SQL tutorials and enhance your database management skills to excel in your tech journey!
No, renaming a column typically only changes its name. All other properties, such as the data type, NULL/NOT NULL constraint, default values, and foreign keys, remain unchanged. The only exception is MySQL's CHANGE command, which requires you to respecify the data type.
This depends on the database system. In PostgreSQL and MySQL, you can chain multiple RENAME COLUMN actions within a single ALTER TABLE statement. However, in SQL Server, you must call the sp_rename procedure separately for each column you want to rename.
The database will prevent this and return an error. Column names within a single table must be unique. You would receive an error message indicating a duplicate column name, and the ALTER TABLE operation would fail.
In most SQL dialects, including PostgreSQL and Oracle, the AS keyword is optional for aliasing. You can simply write the new name after the original column name. However, using AS is considered a best practice because it makes the query clearer and easier to read.
Most modern database systems are intelligent enough to handle this. When you rename a column that is part of a foreign key relationship, the system typically updates the constraint definition automatically. However, it is always a good practice to verify this after the change.
For the simple task of renaming a column, it is better and safer to use RENAME COLUMN. The CHANGE command is more powerful as it can also modify the column's data type, but it requires you to restate the definition, which introduces a risk of accidental changes.
To rename a column, you generally need the ALTER permission on the table. This is a significant permission that allows for changes to the table's structure, so it is typically only granted to database administrators or senior developers.
You cannot directly rename a column within a view's definition using ALTER VIEW. You must redefine the view using CREATE OR REPLACE VIEW and use an alias (AS) in the SELECT statement to give the column a new name in the view's output.
No, renaming a column is a metadata operation that only changes the name of the column in the database schema. It does not affect the actual data stored in the table. The data within the column remains completely intact.
You can use a DESCRIBE or DESC command in systems like MySQL or Oracle (e.g., DESCRIBE table_name;). In PostgreSQL, you can use the \d table_name command in the psql client. You can also query the system's INFORMATION_SCHEMA views.
It is strongly discouraged, but most database systems allow it if you enclose the name in delimiters, such as double quotes (") in PostgreSQL or backticks () in MySQL. For example, RENAME COLUMN old_name TO "SELECT";` would work but is a very bad practice.
No, a simple column rename is a very fast metadata-only change. It does not require a full table scan or a rebuild of any associated indexes. The database system simply updates its internal catalogs to reflect the new name.
A column alias, created with AS, renames a column in the output of a query. A table alias renames a table for the duration of a query (e.g., FROM employees AS e). Table aliases are primarily used to shorten table names in complex queries with many joins.
There is no direct UNDO command. To reverse the change, you would have to execute another ALTER TABLE statement to rename the column back to its original name. This is why testing in a non-production environment is so important.
This is a design choice specific to SQL Server. Using a system stored procedure like sp_rename allows for a single entry point to rename various types of database objects (tables, columns, indexes) by simply changing a parameter, which can be a flexible approach.
Renaming a column typically requires a brief, exclusive lock on the table to update its metadata. This lock is usually very short, but on a very busy system, it could momentarily block other queries from accessing the table.
Yes, you can rename a primary key column just like any other column. The database system will automatically update the primary key constraint to reference the new column name. All associated foreign keys in other tables will also be updated.
A good column name should be descriptive, concise, and consistent with the naming conventions of your project. Avoid using spaces or special characters, and use snake_case (first_name) or camelCase (firstName) depending on your team's standards.
The INFORMATION_SCHEMA is a set of read-only views present in most SQL databases. It provides a standard way to get metadata about the database objects, such as tables, columns, and constraints. You can query it to find column names before renaming them.
A schema change, or schema migration, is any modification to the structure of a database. This includes actions like creating tables, adding or dropping columns, and renaming columns. These are distinct from data changes, which involve inserting, updating, or deleting rows.
408 articles published
Rohan Vats is a Senior Engineering Manager with over a decade of experience in building scalable frontend architectures and leading high-performing engineering teams. Holding a B.Tech in Computer Scie...
Get Free Consultation
By submitting, I accept the T&C and
Privacy Policy
India’s #1 Tech University
Executive PG Certification in AI-Powered Full Stack Development
77%
seats filled
Top Resources