To create
the database using a query
Create database DatabaseName
To
alter a database, once it's created
Alter database DatabaseName Modify Name = NewDatabaseName
Or
sp_renameDB 'OldDatabaseName','NewDatabaseName'
Creating
database with file groups
CREATE DATABASE [FGTest] ON PRIMARY
( NAME = N'exampledb',
FILENAME ='E:\sample.mdf' ,
SIZE = 3072KB , FILEGROWTH = 1024KB ),
FILEGROUP [Secondary] ( NAME ='exampledb2',
FILENAME = N'E:\sampledb2.ndf' ,
SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Example_log',
FILENAME = N'E:\example_log.ldf' ,
SIZE = 1024KB , FILEGROWTH = 10%)
GO
To Delete
or Drop a database
You cannot drop a database, if it is currently in use.
So, if other users are connected, you need to put the
database in single user mode and then drop the database.
Alter Database DatabaseName Set SINGLE_USER With Rollback Immediate
drop database databasename
No comments:
Post a Comment