如何知道我的SQL数据库具有哪种恢复模型?


Answers:


22

如何做...

SELECT D.recovery_model_desc FROM sys.databases D WHERE name = 'MyDB'

要么

SELECT name, D.recovery_model_desc FROM sys.databases D

要么

SELECT DATABASEPROPERTYEX('MyDB', 'Recovery')

6

这是我制作的脚本,用于向我展示数据库文件路径和恢复模型:

SELECT 
  A.recovery_model_desc AS [Recovery Model], 
  A.name AS [Database Name], 
  C.physical_name AS [Filename], 
  CAST(C.size * 8 / 1024.00 AS DECIMAL(10,2)) AS [Size in MB], 
  C.state_desc AS [Database State]
FROM sys.databases A
INNER JOIN sys.master_files C ON A.database_id = C.database_id
ORDER BY [Recovery Model], [Database Name], [Filename]

3

该查询为您提供仅具有简单恢复模型的数据库列表;

SELECT name, DATABASEPROPERTYEX(name, 'Recovery') as Recovery_Model
FROM sys.databases
WHERE DATABASEPROPERTYEX(name, 'Recovery') = 'Simple'
ORDER BY name;
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.