Date Vines

Sql Database

Create Database in Sql Server 2005, Database Statements

Share this site:   

more »
x
  • Google BMs
  • Google Buzz
  • Digg
  • reddit
  • Bebo
  • Tumblr.
  • Myspace
  • Blogger
  • StumbleUpon
  • Del.icio.us
sql database

Following is the full syntax used for creating database in Sql Server 2005.
-------------------------------------------------------------------------------------------------------------------------------------------
CREATE DATABASE databasename
[ ON [ PRIMARY [ < filespec >
LOG ON [ < filespec >
< filespec > : : =
( [ NAME = logicalfilename ,
FILENAME = 'osfilename'
[ , SIZE = size
[ , MAXSIZE = maxsize UNLIMITED
[ , FILEGROWTH = growthincrement ) [ ,.... n

Description ::-
ON specifies the disk file used to store the data portion of the database.
LOG ON specifies the disk files used to store log files.
FILENAME=osfilename specifies the operating-system file name for the file.
PRIMARY specifies the associated <filespec> list that defines files in the primary filegroup.
NAME=logicalfilename specifies the logical name for the file.
MAXSIZE=maxsize specifies the maxium size to which the file defined in the <filespec> list can grow.
FILEGROWTH=growthincrement specifies the growth increment of the file defined in the <filespec> list.
Remember - " FILEGROWTH setting for a file cannot exceed the MAXSIZE setting"
NOTE : Everything written between [ is optional .
But remeber that to create a database you must be a member of the dbcreator server role.
After a database is created, to check details of the database use following command :
sphelpdb [ databasename

To drop a user defined database use following command:
DROP DATABASE databasename

Note: you cannot delete a system-defined database.

To rename a user-defined database use :
sprenamedb olddatabasename , newdatabasename

Fortunately you can also create a database by a right click on the object explorer, Thanks to SQL SERVER Management studio 2005.

SQL SERVER 2005 contains the following system database :

master
tempdb
model
msdb
Resource


--------------------------------------------------------------------------------------------------------------------------------------------


If u have any query feel free to ask. If u like this post , rate & comment it.

Regards,
Anuj Tripathi

Join Our Mailing List!

Deal of the Day

MS SQL SVR WRKGROUP ED 2008 DVD 1 PROC
$3,754.03
Limited Stock.
Don't Miss Out.
Buy Now

Recommended

There are no recommendations at this time. Please check back later.