Tuesday, August 10, 2010

Creating a Database

Database


A database is a collection of information that is organized so that it can easily be accessed, managed, and updated.

create a database:

syntax:  create database database_name

Eg: CREATE DATABASE TEST

database_name is the name of the database. The maximum size of a database name is 128 characters.
SQL server has two operating system file types:

1. Data files (has extension .mdf)

2. Log files ( has extension .ldf)

Data files contain data and objects such as tables and indexes. Log files contain transaction log for recovering the database transactions.

Specifying the data file and log file

Eg:

CREATE DATABASE DBTEST
ON
(
NAME='DBTESTDATA',
FILENAME='E:\jobin\database\DBTESTDATA.mdf',
SIZE=10mb,
MAXSIZE=100mb,
FILEGROWTH=10mb
)


LOG ON
(
NAME='DBTESTLOG',
FILENAME='E:\jobin\database\DBTESTLOG.ldf',
SIZE=5mb,
MAXSIZE=50mb,
FILEGROWTH=5mb
)

No comments: