0% found this document useful (0 votes)
16 views

SQL RENAME Table - Javatpoint

The document discusses how to rename tables in SQL using the RENAME TABLE and ALTER TABLE statements. Both statements allow changing the name of an existing table to a new table name. The RENAME TABLE statement renames the table, while the ALTER TABLE statement modifies the table structure and can also be used to rename the table. Examples are provided demonstrating how to use the RENAME TABLE and ALTER TABLE statements to change table names.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SQL RENAME Table - Javatpoint

The document discusses how to rename tables in SQL using the RENAME TABLE and ALTER TABLE statements. Both statements allow changing the name of an existing table to a new table name. The RENAME TABLE statement renames the table, while the ALTER TABLE statement modifies the table structure and can also be used to rename the table. Examples are provided demonstrating how to use the RENAME TABLE and ALTER TABLE statements to change table names.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Home SQL PL/SQL MySQL MongoDB PostgreSQL SQL Server

SQL RENAME TABLE


In some situations, database administrators and users want to change the name of the table in the SQL
database because they want to give a more relevant name to the table.

Any database user can easily change the name by using the RENAME TABLE and ALTER TABLE
statement in Structured Query Language.

The RENAME TABLE and ALTER TABLE syntax help in changing the name of the table.

Syntax of RENAME statement in SQL

RENAME old_table _name To new_table_name ;

Examples of RENAME statement in SQL


Here, we have taken the following two different SQL examples, which will help you how to change the
name of the SQL table in the database using RENAME statement:

Example 1: Let's take an example of a table named Cars:

Car Name Car Color Car Cost

Hyundai Creta White 10,85,000


Hyundai Venue White 9,50,000

Hyundai i20 Red 9,00,000

Kia Sonet White 10,00,000

Kia Seltos Black 8,00,000

Swift Dezire Red 7,95,000

Table: Cars

Suppose, you want to change the above table name into "Car_2021_Details". For this, you have to
type the following RENAME statement in SQL:

RENAME Cars To Car_2021_Details ;

After this statement, the table "Cars" will be changed into table name "Car_2021_Details".

Example 2: Let's take an example of a table named Employee:

Emp_Id Emp_Name Emp_Salary Emp_City

201 Abhay 25000 Goa

202 Ankit 45000 Delhi

203 Bheem 30000 Goa

204 Ram 29000 Goa

205 Sumit 40000 Delhi


Table: Employee

Suppose, you want to change the name of the above table into the "Coding_Employees". For
this, you have to type the following RENAME statement in SQL:

RENAME Employee To Coding_Employees ;

After this statement, the table "Employee" will be changed into the table name
"Coding_Employees".

Syntax of ALTER TABLE statement in SQL

ALTER TABLE old_table_name RENAME TO new_table_name;

In the Syntax, we have to specify the RENAME TO keyword after the old name of the table.

Examples of ALTER TABLE statement in SQL

Here, we have taken the following three different SQL examples, which will help you how to change the
name of the table in the SQL database using ALTER TABLE statement:

Example 1: Let's take an example of a table named Bikes:

Bike_Name Bike_Color Bike_Cost

KTM DUKE Black 185,000

Royal Enfield Black NULL

Pulsar Red 90,0000


Apache White NULL

Livo Black 80,000

KTM RC Red 195,000

Table : Bikes

Suppose, you want to change the name of the above table into "Bikes_Details" using ALTER
TABLE statement. For this, you have to type the following query in SQL:

ALTER TABLE Bikes RENAME TO Bikes_Details ;

After this statement, the table "Bikes" will be changed into the table name "Bikes_Details".

Example 2: Let's take an example of a table named Student:

Stu_ID Stu_Name Stu_Marks

1001 Abhay 85

1002 Ankit 75

1003 Bheem 60

1004 Ram 79

1005 Sumit 80

Table : Student

Suppose, you want to change the name of the above table into "MCA_Student_Details" using
ALTER TABLE statement. For this, you have to type the following query in SQL:

ALTER TABLE Student RENAME TO MCA_Student_Details ;

After this statement, the table "Student" will be changed into table name "MCA_Student_Details".

Example 3: Let's take an example of a table named Employee:


Emp_Id Emp_Name Emp_Salary Emp_City

201 Abhay 25000 Goa

202 Ankit 45000 Delhi

203 Bheem 30000 Goa

204 Ram 29000 Goa

205 Sumit 40000 Delhi

Table: Employee

Suppose, you want to change the name of the above table into the "Coding_Employees" using
an ALTER TABLE statement. For this, you have to type the following query in SQL:

ALTER TABLE Employee RENAME To Coding_Employees ;

After this statement, the table "Employee" will be changed into the table name "Coding_Employees".

← Prev Next →
Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

Send your Feedback to [email protected]

Help Others, Please Share

Learn Latest Tutorials

Splunk tutorial SPSS tutorial Swagger T-SQL tutorial


tutorial
Splunk SPSS Transact-SQL
Swagger

Tumblr tutorial React tutorial Regex tutorial Reinforcement


learning tutorial
Tumblr ReactJS Regex
Reinforcement
Learning

R Programming RxJS tutorial React Native Python Design


tutorial tutorial Patterns
RxJS
R Programming React Native Python Design
Patterns
Python Pillow Python Turtle Keras tutorial
tutorial tutorial
Keras
Python Pillow Python Turtle

Preparation

Aptitude Logical Verbal Ability Interview


Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions

Company
Interview
Questions
Company Questions

Trending Technologies

Artificial AWS Tutorial Selenium Cloud


Intelligence tutorial Computing
AWS
Artificial Selenium Cloud Computing
Intelligence

Hadoop tutorial ReactJS Data Science Angular 7


Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7

Blockchain Git Tutorial Machine DevOps


Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps
B.Tech / MCA

DBMS tutorial Data Structures DAA tutorial Operating


tutorial System
DBMS DAA
Data Structures Operating System

Computer Compiler Computer Discrete


Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Network Compiler Design
Computer Discrete
Organization Mathematics

Ethical Hacking Computer Software html tutorial


Graphics Tutorial Engineering
Ethical Hacking Web Technology
Computer Graphics Software
Engineering

Cyber Security Automata C Language C++ tutorial


tutorial Tutorial tutorial
C++
Cyber Security Automata C Programming

Java tutorial .Net Python tutorial List of


Framework Programs
Java Python
tutorial
Programs
.Net

Control Data Mining Data


Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse

You might also like