faqts : Computers : Databases : Microsoft SQL Server

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 25 people (68%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Database: Microsoft SQL server: SQL: Database:Operation: Create: How to create a database,using SQL?

Dec 22nd, 2003 12:51
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 December 2003 - 09:48 pm -------------------
Database: Microsoft SQL server: SQL: Database:Operation: Create: How 
to create a database,using SQL?
---
For example, create a database named 'test'
Steps: Overview:
 1. -Open Microsoft SQL server Query Analyzer
 2. -Run the following query
--- cut here ---------------------------------------------------------
CREATE DATABASE Test ON (
 NAME = 'Test',
 FILENAME = 'c:\program files\microsoft sql 
server\mssql\data\test.mdf',
 SIZE = 10,
 MAXSIZE = 50,
 FILEGROWTH = 5
)
LOG ON (
 NAME = 'sa',
 FILENAME = 'c:\program files\microsoft sql 
server\mssql\data\test.ldf',
 SIZE = 5MB,
 MAXSIZE = 25MB,
 FILEGROWTH = 5MB
)
GO
--- cut here ---------------------------------------------------------
 3. -You should see now:
The CREATE DATABASE process is allocating 10.00 MB on disk 'Test'.
The CREATE DATABASE process is allocating 5.00 MB on disk 'sa'.
---
---
In general:
---
CREATE DATABASE <your databasename> ON (
 NAME = '<Databasename>',
 FILENAME = 'c:\program files\microsoft sql server\mssql\data\<your 
databasename>.mdf',
 SIZE = <integer size in megabytes>,
 MAXSIZE = <integer maxsize in megabytes>,
 FILEGROWTH = <integer filegrowth in megabytes>
)
LOG ON (
 NAME = '<your login name>',
 FILENAME = 'c:\program files\microsoft sql server\mssql\data\<your 
databasename>.ldf',
 SIZE = <integer size in megabytes>MB,
 MAXSIZE = <integer maxsize in megabytes>MB,
 FILEGROWTH = <integer filegrowth in megabytes>MB
)
GO
---
[book: see also: Vieira, Robert - Professional SQL Server 2000 
programming - ISBN 1-861004-48-6 - p. 152 'Building a database']
---
---
Internet: see also:
---
Database: Microsoft SQL server: SQL: Operation: Overview:Can you give 
an overview of SQL operations?
http://www.faqts.com/knowledge_base/view.phtml/aid/27560/fid/147
----------------------------------------------------------------------