Building a database using SQL statements

Source: Internet
Author: User
Tags mssql

Building a database using SQL statements

Create a database with three names, the first is the database name after create, the second is the logical name of name, and the third is the physical name of filename.

A. Creating a database that does not specify a file

Create database TestDB--testdb The name--dbms in this name.

B. Creating a database that specifies data and transaction log files

Create database TestDB--testdb The name--dbms in this name.

On--on represents the data file group
(--Main data file
name = ' TestDB ',--logical name
Filename = ' D:\Program files\mssql\data\testdb.mdf ',--Physical name
Size =3MB,--Initial size
Maxsize =10MB,--Upper limit
FileGrowth =1MB--1Mb per increase
),
(--Secondary data file
Name = ' testdb1.ndf ',
Filename = ' D:\Program files\mssql\data\testdb1.ndf ',
Size =3MB,
Maxsize =10MB,
FileGrowth =10%
)
Log on--Journal file
(
Name = ' Testdb_log ',
Filename = ' D:\Program files\mssql\data\testdb_log. LDF ',
Size =3MB,
Maxsize =10MB,
FileGrowth =10%
)
Go (--end of statement)

MDF Master file: All databases must have a primary database file. The main deposit is not only used to save data for the database, but also to store the location of all other files that make up the database.
NDF files: There can be multiple, mainly saving data, but not saving system data.
LDF log file: It is recommended to create more than one file, primarily to save the user's actions on the database, which can be used to recover data.

Building a database using SQL statements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.