Chapter 4 – HOW TO CREATE A USER DEFINED DATABASE IN SQL SERVER

Leave a comment (0) Go to comments

Previous Post

Click on new query a new pane will open in right; there we can write the command to create the database.

SYNTAX: -

CREATE DATABASE DATABASE_NAME

Suppose I want to create a database named as HECTOR

TSQL Statement:

CREATE DATABSE HECTOR

After writing this command we have to select the whole command & click the EXECUTE button or you can press the CTRL+E, this will create a database who’s name is HECTOR.


Chapter 4   HOW TO CREATE A USER DEFINED DATABASE IN SQL SERVER RENAMING A USER DEFINED DATABASE HOW TO CREATE A USER DEFINED DATABASE DROPPING OR DELETING A USER DEFINED DATABSE

NOTE: – SQL is not a case sensitive language.

RENAMING A USER DEFINED DATABASE

You can rename a database name as your requirements, only a system administrator or the database owner can rename a database. As we discussed stored procedures earlier, we can rename a database with the help of a stored procedure "sp_renamedb"

SYNTAX:

sp_renamedb old_database_name, new_database_name

I want to change my database name from HECTOR to SMITH. This will be the following command for renaming my earlier database name.

TSQL STMT.:

sp_renamedb HECTOR, SMITH

Execute this command & this will rename my earlier database.

NOTE: - After renaming the database we have to enter the database with new name that is SMITH & the command for that will be:

TSQL STMT.:

USE SMITH

DROPPING OR DELETING A USER DEFINED DATABSE

You can delete a database when it is no longer required. Only the user with system administration role & the owner of the database can delete the database.

SYNTAX

DROP DATABASE DATABASE_NAME

TSQL Code

DROP DATABASE HECTOR

This command will delete the database SMITH.

NOTE: –

  1. You cannot delete a system defined database.
  2. You can delete or rename a database or table using object explorer on the left side. If you want to delete a database, just right click on the database name & select the rename or delete option as per your requirement. You can also delete a table by selecting it & selecting delete option after right click on it.
EOF - Chapter 4 – HOW TO CREATE A USER DEFINED DATABASE IN SQL SERVER, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.