Tuesday, December 27, 2011

Create Database

Syntax

CREATE DATABASE database_name
[ ON
{ [ PRIMARY ] [ [ ,...n ]
[ , [ ,...n ] ]
[ LOG ON { [ ,...n ] } ] }
]
[ COLLATE collation_name ]
[ WITH ]
]
[;]


Adding Arguments
There are a number of optional arguments that you can supply with the CREATE DATABASE command. You should check your database system's documentation for the specific arguments supported and their usage, but here's an example of supplying arguments when creating a database using Microsoft's SQL Server.

more>>


Example Code
In this example, we are supplying the name and location of the database's data file and transaction log. We are also specifying the initial size of these files (with the SIZE argument), the maximum size it can grow to (with the MAXSIZE argument) and the growth increment of each file (using the FILEGROWTH) argument.

USE master
GO
CREATE DATABASE testDB
ON
( NAME = testDB_dat,
FILENAME = 'c:\program files\microsoft sql server\mssql\data\testDBdat.mdf',
SIZE = 20MB,
MAXSIZE = 70MB,
FILEGROWTH = 5MB )
LOG ON
( NAME = 'testDB_log',
FILENAME = 'c:\program files\microsoft sql server\mssql\data\testDB.ldf',
SIZE = 10MB,
MAXSIZE = 40MB,
FILEGROWTH = 5MB )
GO

No comments: