- Explore [has_child]
- All Courses [subitem]
- AI Career Platform [subitem]
- Hire form us [subitem]
- 1:1 Coaching/Mentoring [subitem]
- Job Board [subitem]
- Institute Partnerships [subitem]
- Resources [has_child]
- Master Classes [subitem]
- Discussion Forum [subitem]
- Coding Playground [subitem]
- Free Courses [subitem]
- Topics [has_child]
- Data Science [subitem]
- Software Development [subitem]
- Company Insights
- Interview Preparation [subitem]
- Python [subitem]
- Programming [subitem]
- Digital Marketing [subitem]
- Web Development [subitem]
- Success Stories [subitem]
Introduction To SQL: A Complete Guide
SQL Commands-An Introduction
Char and Varchar in SQL
ORDER BY in SQL
5 Resume Writing Myths That You Need to Stop Following Now!
GROUP BY in SQL
Learn How to Perform Union in SQL?
Joins and Its Types in SQL
Rename column name in SQL
Learn How To Compare Two Or More Datetime Entities In SQL With Examples
Difference Between SQL and NoSQL
Constraints in SQL
Learn about Aggregate Functions in SQL
SQL Subqueries
Nested Queries in SQL - Query In Query
SQL WITH Clause – Tutorial and Examples
How to Drop a Table in PostgreSQL?
How to Perform Pivot in SQL?
SQL Window Function
Find Nth Highest Salary in SQL
Working of Correlated SubQueries in SQL
Learn about Stored Procedures in SQL
Triggers in SQL: An Overview and Example
PL/SQL Explained
Introduction
Occasionally, we might want to rename our table to something more appropriate. To rename the table, we can use ALTER TABLE for this purpose.
Syntax(Oracle,MySQL,MariaDB):
ALTER TABLE table_name |
Columns can also be given new name with the use of ALTER TABLE.
Syntax(MySQL, Oracle):
ALTER TABLE table_name |
Syntax(MariaDB):
ALTER TABLE table_name ExampleConsider the following table:
To rename ID column(The first column) to user_id the following syntax can be used:
Output:
write your code here: Coding Playground When renaming a column in a table, be cautious. You run the risk of destroying database dependencies when you use ALTER TABLE to rename columns. Instead of using ALTER TABLE to rename a column, a database refactoring tool will take care of all the dependents and update them with the new column name. If you have a tiny database you may not need to worry, but it is crucial to keep in mind. ConclusionIn this article, you have learned how to use ALTER TABLE to add a column and rename a column in a table. |