Search

Saturday, March 1, 2014
0 comments

How to Rename or Drop User-Defined Database in SQL Programming

7:11 PMSaturday, March 1, 2014

Renaming a User-Defined Database

After creating a user-defined database in SQL server, programmer can rename a database whenever required. Only a system administrator or the database owner can rename a database. The sp_renamedb stored procedure is used to rename a database. The syntax of the sp_renamedb statement is:

Sp_renamedb old_database_name, new_database_name
Where

  • old_database_name is the current name of the database
  • new_database_name is the new name of the database 
For example, the following SQL query renames the Personnel database.
Sp_renamedb Personnel Personnel1

Dropping a User-Defined Database

Programmer can delete a database when it is no longer required. This causes all the database files and data to be deleted. Only the users with sysadmin role and the database owner have the permissions to delete a database. The syntax of the DROP DATABASE statement is:

DROP DATABASE database_name
Where
Database_name is the name of the database.

The following SQL query deletes the Employee database:
DROP DATABASE Employee

Programmer cannot delete a system-defined database. Programmer can rename or delete a database using the Object Explorer window by right-clicking the Databases folder and selecting the Rename or Delete option from the shortcut menu.
Create User-Defined Database 
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top