Task1: Create a database with T-SQL statements

Task1: Create a database with T-SQL statements

Example 1:
Create a database named testdb, the database contains a data file and a log file, the
logical file name is testdb_data, the disk file name is testdb_data.mdf/, the
initial capacity of the file is 5MB, the capacity of Xia Da is 15MB, the file The increase is 20%,
and the logical file name of the transaction log file is testdb_log, the disk file name is testdb.ldf, the
initial capacity of the file is 5MB, the maximum capacity is 10MB, and the file increment is 1MB.
(The database is created in C:\ server directory)

  1. Analyzing the meaning of the question, the T-SQL statement to create the testdb database is as follows:
CREATE DATABASE testdb				-- 创建名字为testdb的数据库
ON PRIMARY							-- 数据库文件的SQL语句
(
	NAME='testdb',                           -- 数据文件的逻辑名
	FILENAME='C:\server\testdb_data.mdf',    -- 数据文件的物理名
	SIZE=5MB,                             	 -- 数据文件初始容量
	MAXSIZE=15MB,                            -- 数据文件最大容量
	FILEGROWTH=20%                           -- 数据文件增长量
)
LOG ON
(
	NAME='testdb.ldf',                       -- 日志文件的逻辑名
	​FILENAME='C:\server\testdb.ldf',         -- 日志文件的物理名
	SIZE=5MB,                                -- 日志文件初始容量
	MAXSIZE=10MB,                            -- 日志文件最大容量
	FILEGROWTH=1MB                           -- 日志文件递增量
)
  1. After executing the above T-SQL statement in SQL Server 2014, the effect is as follows:
    Insert picture description here

Guess you like

Origin blog.csdn.net/csdcainiao/article/details/104653014