当前位置: 澳门新濠3559 > 数据库 > 正文

如何恢复数据库备份到一个已存在的正在使用的

时间:2019-11-22 23:13来源:数据库
USEmaster--(Can’tsitinthedatabasewhilstitsbeingrestored!)GOALTERDATABASEMyDatabaseSETSINGLE_USERWITHROLLBACKIMMEDIATEGO--RestoreFullBackupRESTOREDATABASEMyDatabaseFROMDISK=’x:MSSQLBACKUP如何恢复数据库备份到一个已存在的正在

USEmaster--(Can’tsitinthedatabasewhilstitsbeingrestored!)GOALTERDATABASEMyDatabaseSETSINGLE_USERWITHROLLBACKIMMEDIATEGO--RestoreFullBackupRESTOREDATABASEMyDatabaseFROMDISK=’x:MSSQLBACKUP如何恢复数据库备份到一个已存在的正在使用的数据库上_MsSql_脚本之家。MyBackupFilename_Full.BAK’WITHREPLACE,NORECOVERY,--UseifmoreT/Logstorecover--RECOVERY,--UseifNOmoreT/LogstorecoverSTATS=10,--ShowprogressMOVE’MyDatabase_Data’TO’x:MSSQLDATAMyDatabase.mdf’,MOVE’MyDatabase_Log’TO’x:MSSQLDATAMyDatabase.ldf’GO--OptionalrestoreDifferentialBackupRESTOREDATABASEMyDatabaseFROMDISK=’x:MSSQLBACKUPMyDatabase_Diff.BAK’WITH--RECOVERY--UseifNOmorefiletorecoverNORECOVERY--UseifthereareT/LogstorecoverGO--OptionalrestoreTransactionLogBackupRESTOREDATABASEMyDatabaseFROMDISK=’x:MSSQLBACKUPMyDatabase_yyyymmdd_hhmm_Trans.BAK’WITH--RECOVERY--UseifNOmoreT/LogstorecoverNORECOVERY--UseifmoreT/LogstorecoverGO--Setthedatabasereadyforuse(afterallbackupshavebeenrestored)RESTOREDATABASEMyDatabaseRECOVERYGO--Renamelogicalnames(onlyneededifrestoringfromabackupforaDifferentdatabase):ALTERDATABASEMyDatabaseMODIFYFILE(NAME=’OrigDatabase_Data’,NEWNAME=’MyDatabase_data’)GOALTERDATABASEMyDatabaseMODIFYFILE(NAME=’OrigDatabase_Log’,NEWNAME=’MyDatabase_log’)GO

编辑:数据库 本文来源:如何恢复数据库备份到一个已存在的正在使用的

关键词: