Sometimes we may want to rename our table to give it a more relevant name. For this purpose we can use ALTER TABLE to rename the name of table.
*Syntax may vary in different databases.
ALTER TABLE table_name RENAME TO new_table_name;
Columns can be also be given new name with the use of ALTER TABLE.
ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
ALTER TABLE table_name CHANGE COLUMN old_name TO new_name;
- Change the name of column NAME to FIRST_NAME in table Student.
ALTER TABLE Student RENAME COLUMN NAME TO FIRST_NAME;
- Change the name of the table Student to Student_Details
ALTER TABLE Student RENAME TO Student_Details;
This article is contributed by Shubham Chaudhary. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- SQL | ALTER (ADD, DROP, MODIFY)
- Difference between ALTER and UPDATE Command in SQL
- Create, Alter and Drop schema in MS SQL Server
- Alter login in SQL Server
- ALTER SCHEMA in SQL Server
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- MySQL | RENAME USER
- SQL | Procedures in PL/SQL
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between SQL and T-SQL
- Mitigation of SQL Injection Attack using Prepared Statements (Parameterized Queries)
- SQL | SELECT Query
- SQL | Distinct Clause
- SQL | WHERE Clause
- SQL | AND and OR operators
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | SELECT TOP Clause
- SQL | ORDER BY
Improved By : guruvishnu_desireddy