sql備份語句
--完整備份
backup database northwindcs
to disk='g:/backup/northwindcs_full_20070908.bak'
--差異備份
backup database northwindcs
to disk='g:/backup/northwindcs_diff_20070908.bak'
with differential
--日誌備份,預設截斷日誌
backup log northwindcs
to disk='g:/backup/northwindcs_log_20070908.bak'
--日誌備份,不截斷日誌
backup log northwindcs
to disk='g:/backup/northwindcs_log_20070908.bak'
with no_truncate
--截斷日誌不保留
backup log northwindcs
with no_log
--或者
backup log northwindcs
with truncate_only
--截斷之後日誌檔案不會變小
--有必要可以進行收縮
--檔案備份
exec sp_helpdb northwindcs --檢視資料檔案
backup database northwindcs
file='northwindcs' --資料檔案的邏輯名
to disk='g:/backup/northwindcs_file_20070908.bak'
--檔案組備份
exec sp_helpdb northwindcs --檢視資料檔案
backup database northwindcs
filegroup='primary' --資料檔案的邏輯名
to disk='g:/backup/northwindcs_filegroup_20070908.bak'
with init
--分割備份到多個目標
--恢復的時候不允許丟失任何乙個目標
backup database northwindcs
to disk='g:/backup/northwindcs_full_1.bak'
,disk='g:/backup/northwindcs_full_2.bak'
--映象備份
--每個目標都是相同的
backup database northwindcs
to disk='g:/backup/northwindcs_mirror_1.bak'
mirror
to disk='g:/backup/northwindcs_mirror_2.bak'
with format --第一次做映象備份的時候格式化目標
--映象備份到本地和遠端
backup database northwindcs
to disk='g:/backup/northwindcs_mirror_1.bak'
mirror
to disk='//192.168.1.200/backup/northwindcs_mirror_2.bak'
with format
--每天生成乙個備份檔案
--從norecovery或者
--standby模式恢復資料庫為可用
restore database northwindcs_bak
with recovery
--檢視目標備份中的備份集
restore headeronly
from disk ='g:/backup/northwindcs_full_20070908.bak'
--檢視目標備份的第乙個備份集的資訊
restore filelistonly
from disk ='g:/backup/northwindcs_full_20070908_2.bak'
with file=1
--檢視目標備份的卷標
restore labelonly
from disk ='g:/backup/northwindcs_full_20070908_2.bak'
--備份設定密碼保護備份
backup database northwindcs
to disk='g:/backup/northwindcs_full_20070908.bak'
with password = '123',init
restore database northwindcs
from disk='g:/backup/northwindcs_full_20070908.bak'
with password = '123'
SQL Server log備份SQL語句
完全備份 backup database demo to nwdevice02 with name fullbak 日誌備份 backup log demo to nwdevice02 with name log1 restore full backup restore database demo ...
SQL 查詢語句(備份)
分組查詢 1 分組查詢後獲取分組後的前5條資料 1 select from select rid row number over partition by foodparentid order by foodparentid desc from foodlibinfo as t where rid ...
mysql sql 備份表 SQL語句之備份表
select into 語句 表示從乙個表中選取資料,然後把資料插入另乙個表中,常用來備份一張表 1.全表結構備份 select into new table name from old tablename 示例 備份student表,備份表取名為student backup select into...