1、创建数据库
CREATE DATABASE [tt] ON PRIMARY
( NAME = N'tt', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.YUBO2114653\MSSQL\DATA\tt.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'tt_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.YUBO2114653\MSSQL\DATA\tt_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
2、创建数据库并创建名字为Testdat1的文件
CREATE DATABASE Test1 ON
(
NAME = Test1dat1,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.YUBO2114653\MSSQL\DATA\t1dat1.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB
)
3、数据库Test1中新增文件
ALTER DATABASE Test1
ADD FILE
(
NAME = Test1dat2,
FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\t1dat2.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB
)
4、在数据库Test1中新增文件组Test1FG1;并在此文件组中增加两个文件;将此文件组设置为默认文件组
ALTER DATABASE Test1
ADD FILEGROUP Test1FG1
GO
ALTER DATABASE Test1
ADD FILE
( NAME = test1dat3,
FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\t1dat3.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB),
( NAME = test1dat4,
FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\t1dat4.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB)
TO FILEGROUP Test1FG1
ALTER DATABASE Test1
MODIFY FILEGROUP Test1FG1 DEFAULT
GO