1、使用CREATE database创建数据库test
CREATE DATABASE test
ON PRIMARY
( NAME = 'test',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL\data\test.mdf',
SIZE=10240KB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10%)
LOG ON
( NAME='test_log',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL\data\test_log.ldf',
SIZE=1024KB,
MAXSIZE = 5120KB,
FILEGROWTH = 1024KB )
GO
2. 使用ALTER DATABASE语句修改数据库
例4-3 将两个数据文件和一个事务日志文件添加到test数据库中。
程序清单如下:
ALTER DATABASE Test
ADD FILE
(NAME = Test1, FILENAME='c:\Program Files\Microsoft SQL Server\MSSQL\Data\test1.ndf', SIZE =
5MB, MAXSIZE = 100MB, FILEGROWTH = 5MB),
(NAME = Test2, FILENAME='c:\Program Files\Microsoft SQL Server\MSSQL\Data\test2.ndf', SIZE =
3MB, MAXSIZE = 10MB, FILEGROWTH = 1MB)
GO
ALTER DATABASE Test
ADD LOG FILE ( NAME = testlog1, FILENAME='c:\Program Files\Microsoft SQL