資料庫狀態Database States

本主題適用於: 是SQL Server是Azure SQL Database是Azure SQL 資料倉儲 是平行處理資料倉儲 THIS TOPIC APPLIES TO: yesSQL ServeryesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

資料庫永遠都在特定的狀態。A database is always in one specific state. 例如,這些狀態包括 ONLINE、OFFLINE 或 SUSPECT。For example, these states include ONLINE, OFFLINE, or SUSPECT. 若要驗證資料庫目前的狀態,請選取 sys.databases 目錄檢視中的 state_desc 資料行或是在 DATABASEPROPERTYEX 函數中的 Status 屬性。To verify the current state of a database, select the state_desc column in the sys.databases catalog view or the Status property in the DATABASEPROPERTYEX function.

資料庫狀態定義Database State Definitions

下表定義資料表狀態。The following table defines the database states.

StateState 定義Definition
ONLINEONLINE 資料庫可供存取。Database is available for access. 主要檔案群組是在線上,雖然可能尚未完成恢復的恢復階段。The primary filegroup is online, although the undo phase of recovery may not have been completed.
OFFLINEOFFLINE 資料庫是無法使用的。Database is unavailable. 明確的使用者動作可使資料庫變成離線狀態,並且在採取其他的使用者動作之前都是離線狀態。A database becomes offline by explicit user action and remains offline until additional user action is taken. 例如,可以將資料庫設成離線,好讓檔案移到新的磁碟中。For example, the database may be taken offline in order to move a file to a new disk. 在完成移動後,就會將資料庫重新啟動為線上狀態。The database is then brought back online after the move has been completed.
RESTORINGRESTORING 在離線狀態還原主要檔案群組的一或多個檔案,或還原一或多個次要檔案。One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. 資料庫是無法使用的。The database is unavailable.
RECOVERINGRECOVERING 資料庫恢復中。Database is being recovered. 恢復程序是暫時性的狀態;如果恢復成功,資料庫就會自動變成線上狀態。The recovering process is a transient state; the database will automatically become online if the recovery succeeds. 如果恢復失敗,資料庫就會變成有疑問的狀態。If the recovery fails, the database will become suspect. 資料庫是無法使用的。The database is unavailable.
RECOVERY PENDINGRECOVERY PENDING [SQL Server]SQL Server 在恢復期間發生資源相關的錯誤。 has encountered a resource-related error during recovery. 資料庫並未損毀,但是檔案有可能遺失或系統資源限制有可能造成它無法啟動。The database is not damaged, but files may be missing or system resource limitations may be preventing it from starting. 資料庫是無法使用的。The database is unavailable. 需要使用者執行其他動作以解決錯誤並讓恢復處理得以完成。Additional action by the user is required to resolve the error and let the recovery process be completed.
SUSPECTSUSPECT 至少主要檔案群組為有疑問的,而且有可能會損毀。At least the primary filegroup is suspect and may be damaged. 資料庫在 [SQL Server]SQL Server啟動期間無法恢復資料庫。The database cannot be recovered during startup of [SQL Server]SQL Server. 資料庫是無法使用的。The database is unavailable. 需要使用者執行其他動作來解決問題。Additional action by the user is required to resolve the problem.
EMERGENCYEMERGENCY 使用者已變更資料庫並將狀態設為 EMERGENCY。User has changed the database and set the status to EMERGENCY. 資料庫是在單一使用者模式下,而且可以進行修復或還原。The database is in single-user mode and may be repaired or restored. 資料庫是標示為 READ_ONLY、記錄已停用並限定只有 系統管理員 固定伺服器角色的成員才可存取。The database is marked READ_ONLY, logging is disabled, and access is limited to members of the sysadmin fixed server role. EMERGENCY 主要是做為疑難排解的用途。EMERGENCY is primarily used for troubleshooting purposes. 例如,標示為有疑問的資料庫可以設為 EMERGENCY 狀態。For example, a database marked as suspect can be set to the EMERGENCY state. 這將可允許系統管理員唯讀存取資料庫。This could permit the system administrator read-only access to the database. 只有 系統管理員 固定伺服器角色的成員,可以將資料庫設定為 EMERGENCY 狀態。Only members of the sysadmin fixed server role can set a database to the EMERGENCY state.

ALTER DATABASE (Transact-SQL)ALTER DATABASE (Transact-SQL)

鏡像狀態 (SQL Server)Mirroring States (SQL Server)

檔案狀態File States