Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SQL Query to Rename Database

  • Last Updated : 08 Oct, 2021

ALTER SQL command is a DDL (Data Definition Language) statement. ALTER is used to update the structure of the table in the database (like add, delete, modify the attributes of the tables in the database).In this article, we will look at how to rename a database in the SQL server by using the ALTER-Modify keyword. To rename the database we need to create the database first. So, let us create it.

Step 1: Creating Database

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

We are creating the database using CREATE query.

Step 2: CREATE query



The CREATE query is used to create a new database.

Query:

CREATE DATABASE Test

Output:

Step 3: Rename Database

For this, we need to use the ALTER command. ALTER keyword is used to add, delete/drop or modify columns in the existing table. It is also used to add and drop various constraints on the existing table.

  • Renaming means we are modifying the data.
  • Hence, we will use ALTER – MODIFY.

Query:

ALTER DATABASE Test MODIFY NAME = Example

Output:

The database name is changed from Test to Example.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!