使用T-SQL來備份與還原資料庫
–建立一個名叫”puma”的DB
3 |
CREATE DATABASE [puma] ON PRIMARY |
4 |
( NAME = N 'puma' , FILENAME = N 'D:DBpuma.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) |
6 |
( NAME = N 'puma_log' , FILENAME = N 'D:DBpuma_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) |
–備份”puma”DB
1 |
BACKUP DATABASE puma TO DISK = 'D:DBpuma.bak' |
–還原”puma”DB到新的DB”puma2″
2 |
FROM DISK = 'D:DBpuma.bak' |
4 |
MOVE 'puma' TO 'D:DBpuma2.mdf' , |
5 |
MOVE 'puma_log' TO 'D:DBpuma2_log.ldf' , |