sys.pdw_nodes_pdw_physical_databases (Transact-SQL)

适用于:Analytics Platform System (PDW)

包含计算节点上每个物理数据库的行。 聚合物理数据库信息以获取有关数据库的详细信息。 若要合并信息,请sys.pdw_nodes_pdw_physical_databases联接到sys.pdw_database_mappings表。sys.databases

列名称 数据类型 描述
database_id int 数据库的对象 ID。 请注意,此值与 sys.databases (Transact-SQL) 视图中的database_id不同。
physical_name sysname Shell/计算节点上数据库的物理名称。 此值与 sys.pdw_database_mappings (Transact-SQL) 视图中physical_name列中的值相同。
pdw_node_id int 与节点关联的唯一数值 ID。

示例:Analytics Platform System (PDW)

A. 返回

以下查询返回 master 中每个数据库的名称和 ID,以及每个计算节点上的相应数据库名称。

SELECT D.database_id AS DBID_in_master, D.name AS UserDatabaseName,   
PD.pdw_node_id AS NodeID, DM.physical_name AS PhysDBName   
FROM sys.databases AS D  
JOIN sys.pdw_database_mappings AS DM  
    ON D.database_id = DM.database_id  
JOIN sys.pdw_nodes_pdw_physical_databases AS PD  
    ON DM.physical_name = PD.physical_name  
ORDER BY D.database_id, PD.pdw_node_ID;  

B. 使用sys.pdw_nodes_pdw_physical_databases收集详细的对象信息

以下查询显示有关索引的信息,并包含有关对象属于数据库中对象的数据库的有用信息。

SELECT D.name AS UserDatabaseName, D.database_id AS DBIDinMaster,  
DM.physical_name AS PhysDBName, PD.pdw_node_id AS NodeID,   
IU.object_id, IU.index_id, IU.user_seeks, IU.user_scans, IU.user_lookups, IU.user_updates  
FROM sys.databases AS D  
JOIN sys.pdw_database_mappings AS DM  
    ON D.database_id = DM.database_id  
JOIN sys.pdw_nodes_pdw_physical_databases AS PD  
    ON DM.physical_name = PD.physical_name  
JOIN sys.dm_pdw_nodes_db_index_usage_stats AS IU  
    ON PD.database_id = IU.database_id  
ORDER BY D.database_id, IU.object_id, IU.index_id, PD.pdw_node_ID;  

°C 使用sys.pdw_nodes_pdw_physical_databases确定加密状态

以下查询提供 AdventureWorksPDW2012 数据库的加密状态。

WITH dek_encryption_state AS   
(  
    SELECT ISNULL(db_map.database_id, dek.database_id) AS database_id, encryption_state  
    FROM sys.dm_pdw_nodes_database_encryption_keys AS dek  
        INNER JOIN sys.pdw_nodes_pdw_physical_databases AS node_db_map  
            ON dek.database_id = node_db_map.database_id AND dek.pdw_node_id = node_db_map.pdw_node_id  
        LEFT JOIN sys.pdw_database_mappings AS db_map  
            ON node_db_map .physical_name = db_map.physical_name  
        INNER JOIN sys.dm_pdw_nodes AS nodes  
            ON nodes.pdw_node_id = dek.pdw_node_id  
    WHERE dek.encryptor_thumbprint <> 0x  
)  
SELECT TOP 1 encryption_state  
       FROM  dek_encryption_state  
       WHERE dek_encryption_state.database_id = DB_ID('AdventureWorksPDW2012 ')  
       ORDER BY (CASE encryption_state WHEN 3 THEN -1 ELSE encryption_state END) DESC;  

另请参阅

Azure Synapse Analytics 和并行数据仓库目录视图
sys.databases (Transact-SQL)
sys.pdw_database_mappings (Transact-SQL)