Create a database using T-SQL statement

How to use case presentations T-SQL statements to create the database

Syntax

Create a database with the syntax T-SQL statement

CREATE DATABASE database name
the ON [a PRIMARY]
(
<data file parameter> [, ... n] [<parameter file group>]
)
[LOG ON]
(
<log file parameters> [, ... n]
)

Create a database

Of needs
- creating a database StudentDB in SQL Server Management Studio, the inventory data in the C drive folder db
- logical name of the data file is Student_data, the initial size of 3MB. Solid growth in a maximum of 30MB, increase the amount of 1MB
- the logical name of the log file Wei Student_log, the initial size of 1MB, maximum file growth is 10MB, an increase of 10%

Operation
1. First enter the C root directory creationdbFolder
2. Start SQL, the New Query button on the toolbar
3. In the opened tab, enter SQL statements

CREATE DATABASE StudentDB
ON PRIMARY
(
NAME=StudentDB_data,
FILENAME=‘C\db\Student_data.mdf’,
SIZE=3MB,
MAXSIZE=30MB,
FILEGROWTH=1MB
)
LOG ON
(
NAME=StudentDB_log,
FILENAME=‘C\db\Student_log.ldf’,
SIZE=1MB,
MAXSIZE=10MB,
FILEGROWTH=10%
)

Check the code, after confirmation, click on the toolbarcarried outButton
message will pop up tagThe command completed successfully
Observed in the left window, does not appear studentDB database, then right-click to refresh the database

Published an original article · won praise 0 · Views 6

Guess you like

Origin blog.csdn.net/weixin_46491490/article/details/104780618