How to Rename Table Name in SQL?

Learn via video course
FREE
View all courses
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
Topics Covered

Suppose we have two tables in our database named table1 and table2. Although we have an idea about the contents of table1 and table2 but anyone who does not know the internal structure of the database will have a hard time guessing what kind of data both tables have. Thus, it is a requirement to rename these tables.

We can rename table name in SQL by using the following ways::

  • RENAME table statement.
  • ALTER TABLE statement.
  • sp_rename procedure.

RENAME table Statement in SQL

The RENAME TABLE statement can be used to rename table name in SQL. Here we use the RENAME keyword followed by the old name of the table followed by the To keyword followed by the new name of the table.

Syntax

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Example

Imagine we have a table of students containing their name, age, and class. The table would look like the following:

Students Table:

NameAgeClass
Peter1510
Bruce149
Tony159
Clark1611
Loki138

Now imagine this table is named table1. In this example, we will change its name to studentInformation.

ALTER TABLE Statement in SQL

The ALTER TABLE statement is used to rename table name in SQL. Here we use the ALTER TABLE keyword followed by the old name of the table followed by the RENAME TO keyword followed by the new name of the table.

Syntax

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Example

Imagine we have a table of students containing their name, age, and class. The table would look like the following:

Students Table:

NameAgeClass
Peter1510
Bruce149
Tony159
Clark1611
Loki138

Now imagine this table is named table1. In this example, we will change its name to studentInformation.

Renaming a Table in SQL Server (sq_rename in SQL)

The sp_rename is also used to rename table name in SQL. Here we use the sp_rename keyword followed by the old name and the new name of the table separated by a comma.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Syntax

Example

Imagine we have a table of students containing their name, age, and class. The table would look like the following:

Students Table:

NameAgeClass
Peter1510
Bruce149
Tony159
Clark1611
Loki138

Now imagine this table is named table1. In this example, we will change its name to studentInformation.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Conclusion

  • SQL offers multiple methods to rename table name in SQL: RENAME table statement, ALTER TABLE statement, and sp_rename procedure.
  • These methods provide flexibility in renaming tables according to specific requirements.
  • Renaming tables can enhance clarity and organization within a database, improving readability and maintenance.
  • Whether using RENAME TABLE, ALTER TABLE, or sp_rename, SQL users have versatile options to manage table names efficiently.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more