创建数据库:
1 CREATE DATABASE zmr 2 on primary 3 ( 4 name = ‘StudentDB‘, 5 filename = ‘T:\DB\StudentDB.mdf‘, 6 size = 3mb, 7 maxsize = unlimited, 8 filegrowth = 1mb --为0则不允许自动增加空间 9 )
例1:创建一个全部使用默认值的数据库
主要数据文件大小为model数据库主要数据文件的大小。
事务日志大小:512KB或主要数据文件大小的25%。
如没有指定maxsize,可增大到填满所有可用的磁盘空间为止。
create database mytest
例2:创建指定一个数据文件和一个日志文件的数据库
1 create database RShDB 2 on primary 3 ( 4 name = ‘RShDB_Data‘, 5 filename = ‘T:\DB\RShDB_Data.mdf‘, 6 size = 10mb, 7 maxsize = 30mb, 8 filegrowth = 5mb 9 ) 10 log on 11 ( 12 name = ‘RShDB_log‘, 13 filename = ‘T:\DB\RShDB_log.ldf‘, 14 size = 3mb, 15 maxsize = 12mb, 16 filegrowth = 2mb 17 )
例3:创建指定多个数据文件和多个事务日志的数据库
1 create database Students 2 on primary 3 ( 4 name = ‘student_data1‘, 5 filename = ‘T:\DB\student_data1.mdf‘, 6 size = 5mb, 7 maxsize = unlimited, 8 filegrowth = 1mb 9 ), 10 ( 11 name = ‘student_data2‘, 12 filename = ‘T:\DB\student_data2.ndf‘, 13 size = 8mb, 14 maxsize = 20mb, 15 filegrowth = 2mb 16 ) 17 LOG ON 18 ( 19 name = ‘student_log1‘, 20 filename = ‘T:\DB\student_log1.ldf‘, 21 size = 2MB, 22 maxsize = 6mb, 23 filegrowth = 10% 24 ), 25 ( 26 name = ‘student_log2‘, 27 filename = ‘T:\DB\student_log2.ldf‘, 28 size = 3mb, 29 maxsize = 8mb, 30 filegrowth = 1mb 31 )
例4:创建一个数据库,除了有主文件组primary,还有group1,group2