SQL Serverデータベースの変更

4604 ワード

データベース情報の表示
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