用來還原、復原和管理備份的 RESTORE 陳述式 (Transact-SQL)RESTORE Statements for Restoring, Recovering, and Managing Backups (Transact-SQL)

適用於: 是SQL Server是Azure SQL Database (僅限受控執行個體)否Azure Synapse Analytics (SQL DW)否平行處理資料倉儲APPLIES TO: YesSQL Server YesAzure SQL Database (Managed Instance only) NoAzure Synapse Analytics (SQL DW) NoParallel Data Warehouse

此章節描述備份所用的 RESTORE 陳述式。This section describes the RESTORE statements for backups. 除了用來還原和復原備份的主要 RESTORE {DATABASE | LOG} 陳述式之外,還有許多輔助的 RESTORE 陳述式可協助您管理備份和計畫還原順序。In addition to the main RESTORE {DATABASE | LOG} statement for restoring and recovering backups, a number of auxiliary RESTORE statements help you manage your backups and plan your restore sequences. 輔助的 RESTORE 命令包括:RESTORE FILELISTONLY、RESTORE HEADERONLY、RESTORE LABELONLY、RESTORE REWINDONLY 和 RESTORE VERIFYONLY。The auxiliary RESTORE commands include: RESTORE FILELISTONLY, RESTORE HEADERONLY, RESTORE LABELONLY, RESTORE REWINDONLY, and RESTORE VERIFYONLY.

重要

在舊版的 SQL Server 中,任何使用者都可以使用 RESTORE FILELISTONLY、RESTORE HEADERONLY、RESTORE LABELONLY 和 RESTORE VERIFYONLY 等 Transact-SQL 陳述式來取得有關備份組及備份裝置的資訊。In previous versions of SQL Server, any user could obtain information about backup sets and backup devices by using the RESTORE FILELISTONLY, RESTORE HEADERONLY, RESTORE LABELONLY, and RESTORE VERIFYONLY Transact-SQL statements. 因為這些陳述式會揭露有關備份檔案內容的資訊,所以在 SQL Server 2008SQL Server 2008 和更新的版本中,這些陳述式需要 CREATE DATABASE 權限。Because they reveal information about the content of the backup files, in SQL Server 2008SQL Server 2008 and later versions these statements require CREATE DATABASE permission. 與舊版相較,這項需求更能完整地保障備份檔案及備份資訊的安全。This requirement secures your backup files and protects your backup information more fully than in previous versions. 如需這個權限的相關資訊,請參閱 GRANT 資料庫權限 (Transact-SQL)For information about this permission, see GRANT Database Permissions (Transact-SQL).

本節內容In This Section

引數Statement 描述Description
RESTORE (Transact-SQL)RESTORE (Transact-SQL) 描述利用 BACKUP 命令從備份中還原和復原資料庫時,所用的 RESTORE DATABASE 和 RESTORE LOG Transact-SQL 陳述式。Describes the RESTORE DATABASE and RESTORE LOG Transact-SQL statements used to restore and recover a database from backups taken using the BACKUP command. 在所有復原模式之下,資料庫都會使用 RESTORE DATABASE。RESTORE DATABASE is used for databases under all recovery models. 只有完整復原模式和大量記錄復原模式會使用 RESTORE LOG。RESTORE LOG is used only under the full and bulk-logged recovery models. 您也可以利用 RESTORE DATABASE,將資料庫回復為資料庫快照集。RESTORE DATABASE can also be used to revert a database to a database snapshot.
RESTORE 引數 (Transact-SQL)RESTORE Arguments (Transact-SQL) 說明 RESTORE 陳述式及一組相關的輔助陳述式 (RESTORE FILELISTONLY、RESTORE HEADERONLY、RESTORE LABELONLY、RESTORE REWINDONLY 和 RESTORE VERIFYONLY) 之「語法」各章節所描述的引數。Documents the arguments described in the "Syntax" sections of the RESTORE statement and of the associated set of auxiliary statements: RESTORE FILELISTONLY, RESTORE HEADERONLY, RESTORE LABELONLY, RESTORE REWINDONLY, and RESTORE VERIFYONLY. 大部份引數都只得到這六個引數其中一部份的支援。Most of the arguments are supported by only a subset of these six statements. 在每個引數的描述中,都會指出引數所得到的支援。The support for each argument is indicated in the description of the argument.
RESTORE FILELISTONLY (Transact-SQL)RESTORE FILELISTONLY (Transact-SQL) 描述 RESTORE FILELISTONLY Transact-SQL 陳述式,這個陳述式用來傳回含有資料庫清單的結果集,以及備份組所包含的記錄檔。Describes the RESTORE FILELISTONLY Transact-SQL statement, which is used to return a result set containing a list of the database and log files contained in the backup set.
RESTORE HEADERONLY (Transact-SQL)RESTORE HEADERONLY (Transact-SQL) 描述 RESTORE HEADERONLY Transact-SQL 陳述式,這個陳述式用來傳回含有特定備份裝置上的所有備份組之所有備份標頭資訊的結果集。Describes the RESTORE HEADERONLY Transact-SQL statement, which is used to return a result set containing all the backup header information for all backup sets on a particular backup device.
RESTORE LABELONLY (Transact-SQL)RESTORE LABELONLY (Transact-SQL) 描述 RESTORE LABELONLY Transact-SQL 陳述式,這個陳述式用來傳回含有給定備份裝置所識別的備份媒體之相關資訊的結果集。Describes the RESTORE LABELONLY Transact-SQL statement, which is used to return a result set containing information about the backup media identified by the given backup device.
RESTORE REWINDONLY (Transact-SQL)RESTORE REWINDONLY (Transact-SQL) 描述 RESTORE REWINDONLY Transact-SQL 陳述式,這個陳述式用來倒轉和關閉設定 NOREWIND 選項來執行的 BACKUP 或 RESTORE 陳述式,保留了其開啟狀態的磁帶裝置。Describes the RESTORE REWINDONLY Transact-SQL statement, which is used to rewind and close tape devices that were left open by BACKUP or RESTORE statements executed with the NOREWIND option.
RESTORE VERIFYONLY (Transact-SQL)RESTORE VERIFYONLY (Transact-SQL) 描述 RESTORE VERIFYONLY Transact-SQL 陳述式,這個陳述式可用來驗證備份,但不進行還原,同時也會檢查備份組是否已完成,整個備份是否可讀取;它不會嘗試驗證資料的結構。Describes the RESTORE VERIFYONLY Transact-SQL statement, which is used to verify the backup but does not restore it, and checks to see that the backup set is complete and the entire backup is readable; does not attempt to verify the structure of the data.

另請參閱See Also

SQL Server 資料庫的備份與還原Back Up and Restore of SQL Server Databases