SQL and T-SQL

|
Rather Have Fast and Secure Remote
Control?
|
To create a database we use the CREATE DATABASE statement. Let’s look at the syntax for this statement:
CREATE DATABASE database_name
[ ON
[ < filespec > [ ,…n ] ]
[ , < filegroup > [ ,…n ] ]
]
[ LOG ON { < filespec > [ ,…n ] } ]
[ COLLATE collation_name ]
[ FOR LOAD | FOR ATTACH ]
< filespec > ::=
[ PRIMARY ]
( [ NAME = logical_file_name , ]
FILENAME = ‘os_file_name’
[ , SIZE = size ]
[ , MAXSIZE = { max_size | UNLIMITED } ]
[ , FILEGROWTH = growth_increment ] ) [ ,…n ]
< filegroup > ::=
FILEGROUP filegroup_name < filespec > [ ,…n ]
Confusing isn’t it? To brake it down line by line have a look at the following link: Transact-SQL Reference: CREATE DATABASE You can also find this information in the SQL Server Books Online under “CREATE DATABASE”.
For example we are going to create a database called DBbySQL with a 5 MB data file and 1 MB log file. Enter the following statement into the query window.
There are a few things you should note here. First, the USE statement changes the Database context (the database we are working with). In this case, we are adding a new database so we use the master database. Next, the GO command tells SQL Query Analyzer to execute the current batch of Transact-SQL statements. A batch is simply a set of Transact-SQL statements from the last GO command or from the start of the script. It is important to know that GO is not a SQL statement, rather it is a command that you can use to tell SQL Query Analyzer or OSQL (and ISQL for that matter) to send the current batch of Transact-SQL statements to SQL Server.
Written by Mike Aubert - Visit WebsiteNext post in SQL Server:
Introduction to SQL Server Transaction Logs
Next post in Database:
Introduction to SQL Server Transaction Logs
Next post in Programming:
Basic Linux Shell Scripting Concepts
Previous post in SQL Server:
Creating a SQL Server Database
Previous post in Database:
Creating a SQL Server Database
Previous post in Programming:
VBScript Fundamentals for Windows Scripting – WMI
All Tutorials by Category:
- CCDA Study Guide
- CCNA Study Guide Chapter 01
- CCNA Study Guide Chapter 02
- CCNA Study Guide Chapter 03
- CCNA Study Guide Chapter 04
- CCNA Study Guide Chapter 05
- CCNA Study Guide Chapter 06
- CCNA Study Guide Chapter 07
- CCNA Study Guide Chapter 08
- CCNA Study Guide Chapter 09
- CCNA Study Guide Chapter 10
- CCNA Study Guide Chapter 11
- CCNA Study Guide Chapter 12
- Cognos
- Computer Hardware
A
C
D
E
F
G
H
I
L
M
N
Entire site Copyright © 1999-2007 2000Trainers.com, all rights reserved.
Content on this site may not be copied or reproduced in any way without permission.


