SQL Rename Database

When you want to rename the database then firstly check new database name should not exist.

Syntax:-


RENAME DATABASE oldDatabaseName TO newDatabaseName

Example:-

Suppose you have database employee_management and you want to change the name to employee_system and you want to use below command


RENAME DATABASE employee_management TO employee_system

Now, you can check the database name is changed through below command


SHOW DATABASES

Output:-

employee_system

SQL Rename Database – Interview Questions

Q 1: What is database renaming?
Ans: Renaming a database means changing its existing name to a new one.
Q 2: Is RENAME DATABASE supported in SQL?
Ans: Most databases do not directly support RENAME DATABASE. Alternative methods are used.
Q 3: How can a database be renamed?
Ans: By creating a new database and moving data, or using DB-specific commands.
Q 4: Does renaming affect data?
Ans: No, data remains unchanged if the process is done correctly.
Q 5: Is renaming database risky?
Ans: Yes, it should be done carefully to avoid data loss or downtime.

SQL Rename Database – Objective Questions (MCQs)

Q1. Which SQL statement is commonly used to rename a database in MySQL?






Q2. What is the correct syntax to rename a database?






Q3. Renaming a database affects:






Q4. ALTER DATABASE is part of which SQL category?






Q5. Which permission is required to rename a database?






Related SQL Rename Database Topics