How to Rename a Column in SQL
James Reed
Infrastructure Engineer ยท Leapcell

Key Takeaways
- Column renaming syntax differs across SQL databases.
- Always check dependencies before renaming a column.
- Back up your data before structural changes.
Renaming a column in an SQL table is a common task when maintaining or refactoring a database. Whether you want to make column names more descriptive, fix a typo, or align with new business requirements, SQL provides several methods to rename columns. This article will guide you through the different approaches depending on your SQL database system.
Why Rename Columns?
There are various reasons for renaming columns in a database:
- Improving clarity: Making column names more descriptive or readable.
- Correcting mistakes: Fixing spelling errors or inconsistencies.
- Adapting to changes: Reflecting new requirements or standards.
General SQL Syntax
There is no universal SQL standard for renaming columns, so the exact syntax depends on your database system (e.g., MySQL, PostgreSQL, SQL Server, Oracle). Below are the most common methods for the major SQL databases.
Renaming Columns in Different SQL Databases
1. MySQL
In MySQL, you can use the ALTER TABLE
statement with the CHANGE
keyword:
ALTER TABLE table_name CHANGE old_column_name new_column_name column_definition;
Example:
ALTER TABLE employees CHANGE fullname full_name VARCHAR(100);
Note: You must specify the column's data type after the new column name.
2. PostgreSQL
PostgreSQL offers a simpler syntax using the RENAME COLUMN
clause:
ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
Example:
ALTER TABLE employees RENAME COLUMN fullname TO full_name;
3. SQL Server
In SQL Server, you use the stored procedure sp_rename
:
EXEC sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN';
Example:
EXEC sp_rename 'employees.fullname', 'full_name', 'COLUMN';
4. Oracle
Oracle Database uses a similar syntax to PostgreSQL:
ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
Example:
ALTER TABLE employees RENAME COLUMN fullname TO full_name;
Important Considerations
- Back up your data: Always back up your table or database before performing structural changes.
- Check for dependencies: Renaming columns might affect views, stored procedures, scripts, or applications that reference the old column name.
- Permissions: Ensure you have the necessary permissions to alter table structures.
Conclusion
Renaming a column in SQL is a straightforward task, but the syntax varies depending on the database you are using. Always check your databaseโs documentation and test changes in a development environment before applying them in production. By following the methods described above, you can easily rename columns and keep your database organized and up to date.
FAQs
Use ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
Use ALTER TABLE table_name CHANGE old_name new_name column_definition;
Renaming columns can break dependencies like views or scripts.
We are Leapcell, your top choice for hosting backend projects.
Leapcell is the Next-Gen Serverless Platform for Web Hosting, Async Tasks, and Redis:
Multi-Language Support
- Develop with Node.js, Python, Go, or Rust.
Deploy unlimited projects for free
- pay only for usage โ no requests, no charges.
Unbeatable Cost Efficiency
- Pay-as-you-go with no idle charges.
- Example: $25 supports 6.94M requests at a 60ms average response time.
Streamlined Developer Experience
- Intuitive UI for effortless setup.
- Fully automated CI/CD pipelines and GitOps integration.
- Real-time metrics and logging for actionable insights.
Effortless Scalability and High Performance
- Auto-scaling to handle high concurrency with ease.
- Zero operational overhead โ just focus on building.
Explore more in the Documentation!
Follow us on X: @LeapcellHQ