RESTORE 陳述式 - FILELISTONLY (Transact-SQL)RESTORE Statements - FILELISTONLY (Transact-SQL)

適用於: 是SQL Server 是Azure SQL Database (僅限受控執行個體) 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database (Managed Instance only) noAzure SQL Data Warehouse noParallel Data Warehouse

傳回含有 SQL ServerSQL Server 中資料庫清單的結果集及備份組所包含的記錄檔。Returns a result set containing a list of the database and log files contained in the backup set in SQL ServerSQL Server.

注意

如需引數的描述,請參閱 RESTORE 引數 (Transact-SQL)For the descriptions of the arguments, see RESTORE Arguments (Transact-SQL).

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

  
RESTORE FILELISTONLY   
FROM <backup_device>   
[ WITH   
 {  
--Backup Set Options  
   FILE = { backup_set_file_number | @backup_set_file_number }   
 | PASSWORD = { password | @password_variable }   
  
--Media Set Options  
 | MEDIANAME = { media_name | @media_name_variable }   
 | MEDIAPASSWORD = { mediapassword | @mediapassword_variable }  
  
--Error Management Options  
 | { CHECKSUM | NO_CHECKSUM }   
 | { STOP_ON_ERROR | CONTINUE_AFTER_ERROR }  
  
--Tape Options  
 | { REWIND | NOREWIND }   
 | { UNLOAD | NOUNLOAD }    
 } [ ,...n ]  
]  
[;]  
  
<backup_device> ::=  
{   
   { logical_backup_device_name |  
      @logical_backup_device_name_var }  
   | { DISK | TAPE | URL } = { 'physical_backup_device_name' |  
       @physical_backup_device_name_var }   
}  
  

注意

URL 是用來指定 Microsoft Azure Blob 儲存體位置和檔案名稱的格式,從 SQL Server 2012 (11.x)SQL Server 2012 (11.x) SP1 CU2 開始支援。URL is the format used to specify the location and the file name for Microsoft Azure Blob Storage and is supported starting with SQL Server 2012 (11.x)SQL Server 2012 (11.x) SP1 CU2. 雖然 Microsoft Azure 儲存體是一項服務,但其實作方式類似於磁碟和磁帶,以便為這三種裝置提供一致且順暢的還原體驗。Although Microsoft Azure storage is a service, the implementation is similar to disk and tape to allow for a consistent and seamless restore experience for all the three devices.

引數Arguments

如需 RESTORE FILELISTONLY 引數的描述,請參閱 RESTORE 引數 (Transact-SQL)For descriptions of the RESTORE FILELISTONLY arguments, see RESTORE Arguments (Transact-SQL).

結果集Result Sets

用戶端可以利用 RESTORE FILELISTONLY 來取得備份組所包含的檔案清單。A client can use RESTORE FILELISTONLY to obtain a list of the files contained in a backup set. 這項資訊會當做結果集傳回,其中針對每個檔案各包含一個資料列。This information is returned as a result set containing one row for each file.

資料行名稱Column name 資料類型Data type DescriptionDescription
LogicalNameLogicalName nvarchar(128)nvarchar(128) 檔案的邏輯名稱。Logical name of the file.
PhysicalNamePhysicalName nvarchar(260)nvarchar(260) 檔案的實體或作業系統名稱。Physical or operating-system name of the file.
類型Type char(1)char(1) 這是檔案的類型,它有下列幾種:The type of file, one of:

L = Microsoft SQL ServerSQL Server 記錄檔L = Microsoft SQL ServerSQL Server log file

D = SQL ServerSQL Server 資料檔D = SQL ServerSQL Server data file

F = 全文檢索目錄F = Full Text Catalog

S = FileStream、FileTable 或 記憶體內部 OLTPIn-Memory OLTP 容器S = FileStream, FileTable, or 記憶體內部 OLTPIn-Memory OLTP container
FileGroupNameFileGroupName nvarchar(128) NULLnvarchar(128) NULL 檔案所在的檔案群組名稱。Name of the filegroup that contains the file.
大小Size numeric(20,0)numeric(20,0) 目前的大小 (以位元組為單位)。Current size in bytes.
MaxSizeMaxSize numeric(20,0)numeric(20,0) 允許的大小上限 (以位元組為單位)。Maximum allowed size in bytes.
FileIDFileID bigintbigint 檔案的識別碼,它在資料庫中是唯一的。File identifier, unique within the database.
CreateLSNCreateLSN numeric(25,0)numeric(25,0) 建立檔案的記錄序號。Log sequence number at which the file was created.
DropLSNDropLSN numeric(25,0) NULLnumeric(25,0) NULL 卸除檔案的記錄序號。The log sequence number at which the file was dropped. 如果檔案尚未卸除,這個值就是 NULL。If the file has not been dropped, this value is NULL.
UniqueIDUniqueID uniqueidentifieruniqueidentifier 檔案的全域唯一識別碼。Globally unique identifier of the file.
ReadOnlyLSNReadOnlyLSN numeric(25,0) NULLnumeric(25,0) NULL 包含從讀寫改成唯讀 (最近的變更) 的檔案之檔案群組所在的記錄序號。Log sequence number at which the filegroup containing the file changed from read-write to read-only (the most recent change).
ReadWriteLSNReadWriteLSN numeric(25,0) NULLnumeric(25,0) NULL 包含從唯讀改成讀寫 (最近的變更) 的檔案之檔案群組所在的記錄序號。Log sequence number at which the filegroup containing the file changed from read-only to read-write (the most recent change).
BackupSizeInBytesBackupSizeInBytes bigintbigint 這個檔案的備份大小 (以位元組為單位)。Size of the backup for this file in bytes.
SourceBlockSizeSourceBlockSize intint 檔案所在實體裝置 (不是備份裝置) 的區塊大小 (以位元組為單位)。Block size of the physical device containing the file in bytes (not the backup device).
FileGroupIDFileGroupID intint 檔案群組的識別碼。ID of the filegroup.
LogGroupGUIDLogGroupGUID uniqueidentifier NULLuniqueidentifier NULL NULL。NULL.
DifferentialBaseLSNDifferentialBaseLSN numeric(25,0) NULLnumeric(25,0) NULL 如果是差異備份,記錄序號大於或等於 DifferentialBaseLSN 的變更會併入差異備份中。For differential backups, changes with log sequence numbers greater than or equal to DifferentialBaseLSN are included in the differential.

如果是其他備份類型,這個值就是 NULL。For other backup types, the value is NULL.
DifferentialBaseGUIDDifferentialBaseGUID uniqueidentifier NULLuniqueidentifier NULL 如果是差異備份,就是差異基底的唯一識別碼。For differential backups, the unique identifier of the differential base.

如果是其他備份類型,這個值就是 NULL。For other backup types, the value is NULL.
IsReadOnlyIsReadOnly bitbit 1 = 檔案唯讀。1 = The file is read-only.
IsPresentIsPresent bitbit 1 = 檔案在備份中。1 = The file is present in the backup.
TDEThumbprintTDEThumbprint varbinary(32) NULLvarbinary(32) NULL 顯示資料庫加密金鑰的指模。Shows the thumbprint of the Database Encryption Key. 加密程式指模是用來加密金鑰的憑證 SHA-1 雜湊。The encryptor thumbprint is a SHA-1 hash of the certificate with which the key is encrypted. 如需資料庫加密的詳細資訊,請參閱透明資料加密 (TDE)For information about database encryption, see Transparent Data Encryption (TDE).
SnapshotURLSnapshotURL nvarchar(360) NULLnvarchar(360) NULL FILE_SNAPSHOT 備份中包含之資料庫檔案的 Azure 快照集 URL。The URL for the Azure snapshot of the database file contained in the FILE_SNAPSHOT backup. 如果沒有 FILE_SNAPSHOT 備份,則傳回 NULL。Returns NULL if no FILE_SNAPSHOT backup.

SecuritySecurity

備份作業可以選擇性地指定媒體集的密碼及 (或) 備份組的密碼。A backup operation may optionally specify passwords for a media set, a backup set, or both. 當在媒體集或備份組上定義密碼時,您必須在 RESTORE 陳述式中,指定一個或多個正確的密碼。When a password has been defined on a media set or backup set, you must specify the correct password or passwords in the RESTORE statement. 這些密碼可以防止他人利用 MicrosoftMicrosoft SQL ServerSQL Server 工具,在未經授權的情況下,對媒體執行還原作業及附加備份組。These passwords prevent unauthorized restore operations and unauthorized appends of backup sets to media using MicrosoftMicrosoft SQL ServerSQL Server tools. 不過,密碼無法防止使用者利用 BACKUP 陳述式的 FORMAT 選項來覆寫媒體。However, a password does not prevent overwrite of media using the BACKUP statement's FORMAT option.

重要

這個密碼所提供的保護很弱。The protection provided by this password is weak. 這是為了防止已獲授權或未獲授權的使用者使用 SQL ServerSQL Server 工具進行不正確的還原。It is intended to prevent an incorrect restore using SQL ServerSQL Server tools by authorized or unauthorized users. 它無法防止透過其他方式或以取代密碼的方式來讀取備份資料。It does not prevent the reading of the backup data by other means or the replacement of the password. 這項功能處於維護模式,並可能在 Microsoft SQL Server 的未來版本中移除。This feature is in maintenance mode and may be removed in a future version of Microsoft SQL Server. 請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。Avoid using this feature in new development work, and plan to modify applications that currently use this feature. 保護備份的最佳作法是將備份磁帶存放在安全位置,或備份至適當的存取控制清單 (ACL) 所保護的磁碟檔案中。The best practice for protecting backups is to store backup tapes in a secure location or back up to disk files that are protected by adequate access control lists (ACLs). ACL 應該設在備份建立所在的根目錄下。The ACLs should be set on the directory root under which backups are created.

權限Permissions

SQL Server 2008SQL Server 2008 開始,取得有關備份組或備份裝置的資訊需要 CREATE DATABASE 權限。Beginning in SQL Server 2008SQL Server 2008, obtaining information about a backup set or backup device requires CREATE DATABASE permission. 如需詳細資訊,請參閱 GRANT 資料庫權限 (Transact-SQL)For more information, see GRANT Database Permissions (Transact-SQL).

範例Examples

下列範例會從名稱為 AdventureWorksBackups 的備份裝置傳回資訊。The following example returns the information from a backup device named AdventureWorksBackups. 此範例使用 FILE 選項指定裝置的第二個備份組。The example uses the FILE option to specify the second backup set on the device.

RESTORE FILELISTONLY FROM AdventureWorksBackups   
   WITH FILE=2;  
GO  

另請參閱See Also

BACKUP (Transact-SQL) BACKUP (Transact-SQL)
媒體集、媒體家族與備份組 (SQL Server) Media Sets, Media Families, and Backup Sets (SQL Server)
RESTORE REWINDONLY (Transact-SQL) RESTORE REWINDONLY (Transact-SQL)
RESTORE VERIFYONLY (Transact-SQL) RESTORE VERIFYONLY (Transact-SQL)
RESTORE (Transact-SQL) RESTORE (Transact-SQL)
備份記錄與標頭資訊 (SQL Server)Backup History and Header Information (SQL Server)