SQL Server 修改数据库

查看数据库信息

execute sp_helpdb Northwind

删除数据库

包括其中所有数据文件,在不使用本数据库的状态下才能执行。

drop database Northwind

修改数据库名

alter database Northwind modify name=Northwind_000

增添数据文件组3

alter database Northwind add filegroup G3

给文件组3增添数据文件

alter database Northwind add file
(   name=NorthwindG31,
    filename='d:\Northwind\NorthwindG31.ndf',
    size=1,maxsize=3,filegrowth=1
),
(   name=NorthwindG32,
    filename='d:\Northwind\NorthwindG32.ndf',
    size=1,maxsize=3,filegrowth=1
)
to filegroup G3

给文件组3增添日志文件

alter database Northwind add log file
(   name=NorthwindLog3,
    filename='d:\Northwind\Northwind3.ldf',
    size=1,maxsize=5,filegrowth=1
),
(   name=NorthwindLog4,
    filename='d:\Northwind\Northwind4.ldf',
    size=1,maxsize=5,filegrowth=1
)

修改数据文件属性

alter database Northwind modify file
(   name=NorthwindG31, --要修改的文件,不可修改 filename
    size=2,maxsize=6,filegrowth=2 --指定的 size 必须大于当前值
)

删除数据文件

alter database Northwind remove file Northwind2
--alter database Northwind remove file NorthwindLog
alter database Northwind remove file NorthwindLog2
alter database Northwind remove file NorthwindLog3
alter database Northwind remove file NorthwindLog4
alter database Northwind remove file NorthwindG31
alter database Northwind remove file NorthwindG32

先删除文件组中的文件,再删除文件组

alter database Northwind remove filegroup G3
alter database Northwind remove file NorthwindG21
alter database Northwind remove file NorthwindG22
alter database Northwind remove filegroup G2
alter database Northwind remove file NorthwindG11
alter database Northwind remove file NorthwindG12
alter database Northwind remove filegroup G1

你可能感兴趣的:(数据库)