Rename Database in SQL
Sometimes you need to change the name of an existing database for technical or organizational reasons ÔÇö for example when the current name no longer reflects the data, or during maintenance/migration. SQL provides ways to rename a database, though the syntax differs by system.
Complete Python Course with Advance topics:-
SQL Tutorial:-
Rename in SQL Server
ALTER DATABASE old_database_name
MODIFY NAME = new_database_name;
-- Or using stored procedure
EXEC sp_renamedb 'old_name', 'new_name';
Rename in MySQL
MySQL removed the old RENAME DATABASE command for safety. The recommended approach is to create a new database and move the tables:
CREATE DATABASE new_db;
RENAME TABLE old_db.table1 TO new_db.table1;
-- repeat for each table, then
DROP DATABASE old_db;
Example: Renaming Student to College
ALTER DATABASE Student MODIFY NAME = College;
Considerations When Renaming
- Connections: Ensure no active connections; use single-user mode.
- Backup: Always back up before renaming.
- Permissions: Only admins can rename databases.
- Avoid Conflicts: The new name must not already exist.
Download New Real Time Projects:- Click here
Complete Advance AI topics:-
Conclusion
Renaming a database is straightforward in SQL Server with ALTER DATABASE, while MySQL requires moving tables to a new database. Always back up first and verify names. For more SQL tutorials, visit .
rename database mysql
rename database in sql server using query
rename database in sql w3schools
rename database mysql workbench
rename database phpmyadmin
rename database mariadb
alter database modify name
sp_renamedb