How to Drop Database in SQL Server

aimtocode

SQL Database: Definition

The Rename DATABASE Statement is used to Rename or catagorize the database. Renaming of the database will Rename only the name of database the inner objects (tables, views, procedures etc.) inside it will be as it is. The user should have admin privileges for deleting a database.

It means the SQL Rename DATABASE statement is used to Rename an existing database in SQL schema.

Syntax:

                  
  RENAME DATABASE old_db_name TO new_db_name;  

Example:

Make sure you have the admin privilege before Renameping any database.


  RENAME DATABASE demoDB TO testDB;  


Once you finish Renameing the database you can see the changes in your database by using SQL SHOW DATABASES like this.

SQL> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| FRUITS             |
| aimtocode              |
| mysql              |
| orig               |
| test               | 
| testDb             |
+--------------------+
6 rows in set (0.00 sec)

The Rename TABLE statement permanently renames the name of database, You can rename it again by using the same query.

aimtocode