从设备还原备份 (SQL Server)Restore a Backup from a Device (SQL Server)

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

本主题说明如何使用 SQL Server 2019 (15.x)SQL Server 2019 (15.x)SQL Server Management StudioSQL Server Management StudioTransact-SQLTransact-SQL中从设备还原备份。This topic describes how to restore a backup from a device in SQL Server 2019 (15.x)SQL Server 2019 (15.x) by using SQL Server Management StudioSQL Server Management Studio or Transact-SQLTransact-SQL.

备注

有关 SQL Server 备份到 Azure Blob 存储服务的信息,请参阅 使用 Microsoft Azure Blob 存储服务进行 SQL Server 备份和还原For information on SQL Server backup to the Azure Blob storage service, see, SQL Server Backup and Restore with Microsoft Azure Blob Storage Service.

本主题内容In This Topic

开始之前Before You Begin

SecuritySecurity

权限Permissions

如果不存在要还原的数据库,则用户必须有 CREATE DATABASE 权限才能执行 RESTORE。If the database being restored does not exist, the user must have CREATE DATABASE permissions to be able to execute RESTORE. 如果数据库存在,则 RESTORE 权限默认授予 sysadmindbcreator 固定服务器角色成员以及数据库的所有者 (dbo)(对于 FROM DATABASE_SNAPSHOT 选项,数据库始终存在)。If the database exists, RESTORE permissions default to members of the sysadmin and dbcreator fixed server roles and the owner (dbo) of the database (for the FROM DATABASE_SNAPSHOT option, the database always exists).

RESTORE 权限被授予那些成员身份信息始终可由服务器使用的角色。RESTORE permissions are given to roles in which membership information is always readily available to the server. 因为只有在固定数据库可以访问且没有损坏时(在执行 RESTORE 时并不会总是这样)才能检查固定数据库角色成员身份,所以 db_owner 固定数据库角色成员没有 RESTORE 权限。Because fixed database role membership can be checked only when the database is accessible and undamaged, which is not always the case when RESTORE is executed, members of the db_owner fixed database role do not have RESTORE permissions.

使用 SQL Server Management StudioUsing SQL Server Management Studio

从设备还原备份To restore a backup from a device

  1. 连接到相应的 MicrosoftMicrosoft SQL Server 数据库引擎SQL Server Database Engine实例之后,在对象资源管理器中,单击服务器名称以展开服务器树。After connecting to the appropriate instance of the MicrosoftMicrosoft SQL Server 数据库引擎SQL Server Database Engine, in Object Explorer, click the server name to expand the server tree.

  2. 展开 “数据库” ,然后根据数据库的不同,选择用户数据库,或展开 “系统数据库” ,再选择系统数据库。Expand Databases, and, depending on the database, either select a user database or expand System Databases and select a system database.

  3. 右键单击数据库,指向“任务” ,再单击“还原” 。Right-click the database, point to Tasks, and then click Restore.

  4. 单击所需的还原操作类型(“数据库” 、“文件和文件组” 或“事务日志” )。Click the type of restore operation you want (Database, Files and Filegroups, or Transaction Log). 这将打开相应的还原对话框。This opens the corresponding restore dialog box.

  5. “常规” 页的 “还原的源” 部分,单击 “源设备”On the General page, in the Restore source section, click From device.

  6. 单击 “源设备” 文本框中的浏览按钮,这将打开 “指定备份” 对话框。Click the browse button for the From device text box, which opens the Specify Backup dialog box.

  7. “备份介质” 文本框中,选择 “备份设备” ,然后单击 “添加” 按钮以打开 “选择备份设备” 对话框。In the Backup media text box, select Backup Device, and click the Add button to open the Select Backup Device dialog box.

  8. “备份设备” 文本框中,选择要用于还原操作的设备。In the Backup device text box, select the device you want to use for the restore operation.

使用 Transact-SQLUsing Transact-SQL

从设备还原备份To restore a backup from a device

  1. 连接到 数据库引擎Database EngineConnect to the 数据库引擎Database Engine.

  2. 在标准菜单栏上,单击 “新建查询”From the Standard bar, click New Query.

  3. RESTORE 语句中,指定用于备份操作的逻辑备份设备或物理备份设备。In the RESTORE statement, specify a logical or physical backup device to use for the backup operation. 此示例从具有物理名称 Z:\SQLServerBackups\AdventureWorks2012.bak的磁盘文件还原。This example restores from a disk file that has the physical name Z:\SQLServerBackups\AdventureWorks2012.bak.

RESTORE DATABASE AdventureWorks2012  
   FROM DISK = 'Z:\SQLServerBackups\AdventureWorks2012.bak' ;  
  

另请参阅See Also

RESTORE FILELISTONLY (Transact-SQL) RESTORE FILELISTONLY (Transact-SQL)
RESTORE HEADERONLY (Transact-SQL) RESTORE HEADERONLY (Transact-SQL)
RESTORE LABELONLY (Transact-SQL) RESTORE LABELONLY (Transact-SQL)
RESTORE VERIFYONLY (Transact-SQL) RESTORE VERIFYONLY (Transact-SQL)
在简单恢复模式下还原数据库备份 (Transact-SQL) Restore a Database Backup Under the Simple Recovery Model (Transact-SQL)
Restore a Database Backup Using SSMS Restore a Database Backup Using SSMS
还原差异数据库备份 (SQL Server) Restore a Differential Database Backup (SQL Server)
将数据库还原到新位置 (SQL Server) Restore a Database to a New Location (SQL Server)
备份文件和文件组 (SQL Server) Back Up Files and Filegroups (SQL Server)
备份事务日志 (SQL Server) Back Up a Transaction Log (SQL Server)
创建差异数据库备份 (SQL Server)Create a Differential Database Backup (SQL Server)