0% found this document useful (0 votes)
31 views9 pages

Create Database by Using Statement

This document provides instructions for creating, renaming, and dropping Microsoft SQL Server databases. It describes three ways to create a database: using a SQL statement, the graphic tool in Object Explorer, or a template. Renaming and dropping a database can be done with SQL statements or the graphic tool by right clicking the database in Object Explorer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

Create Database by Using Statement

This document provides instructions for creating, renaming, and dropping Microsoft SQL Server databases. It describes three ways to create a database: using a SQL statement, the graphic tool in Object Explorer, or a template. Renaming and dropping a database can be done with SQL statements or the graphic tool by right clicking the database in Object Explorer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Contents

1.

Create database......................................................................................................... 1
Create database by using statement....................................................................................1
Create database by graphic tool........................................................................................ 1
Create database by using a template...................................................................................3

2. Rename a database........................................................................................................ 6
Rename database by using statement..................................................................................6
Rename database by graphic tool...................................................................................... 6
3. Drop a database............................................................................................................ 7
Drop database by using statement...................................................................................... 7
Drop database by using graphic tool...................................................................................7

1. Create database
We can create a database by one of following way:

Create database by using statement.


- In the SSMS enters following statement and clicks Execute. A database named Fsoft_Training will be
created.

CREATE DATABASE Fsoft_Training

Create database by graphic tool


- In Object Explorer, right clicks on Database and choose New Database...

- In the New Database dialog, enter Fsoft_Training in the Database name textbox.
We can change location for mdf and ldf file in database files
Each database has at least one mdf file
ldf file is a transaction log file. In real world, we should store mdf and ldf in the separate hard disk drive.
Click OK button to create the database

Create database by using a template


- Choose Template Explorer in the View menu

- Double click on Create Database under Database folder

- Just enter database name in the script and run Execute as below

2. Rename a database
Rename database by using statement
- Use the below statement in order to rename the database.

USE master;
GO
ALTER DATABASE Fsoft_Training
Modify Name = Fsoft_Training2 ;
GO

Rename database by graphic tool


- In the Object Explorer, right click on the database and choose Rename

3. Drop a database
Drop database by using statement
- Copy and Paste below statement and click Execute

USE master
GO
DROP DATABASE Fsoft_Training
GO

Drop database by using graphic tool.


- Right click on the database and choose Delete

- In the Delete Object dialog, make sure Close existing connections is checked and then click OK

You might also like