You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看Snowflake中已应用的用户级网络策略及用户关联关系?

Absolutely! Snowflake has you covered with built-in system views that make it easy to track which user-level network policies are applied to which users, plus view all existing policies. Here's how to pull that information:

Query Applied User-Level Network Policies & Associated Users

To see every network policy attached to a user, along with key details about the policy and user, run this query:

SELECT
  np.POLICY_NAME,
  np.POLICY_TYPE,
  pr.REFERENCE_ENTITY_NAME AS ASSIGNED_USER,
  pr.REFERENCE_ENTITY_TYPE AS ENTITY_TYPE,
  np.CREATED_ON,
  np.LAST_ALTERED
FROM
  ACCOUNT_USAGE.NETWORK_POLICIES np
JOIN
  ACCOUNT_USAGE.POLICY_REFERENCES pr
ON
  np.POLICY_ID = pr.POLICY_ID
WHERE
  pr.REFERENCE_ENTITY_TYPE = 'USER'
ORDER BY
  np.POLICY_NAME, ASSIGNED_USER;

What this does:

  • Joins ACCOUNT_USAGE.NETWORK_POLICIES (stores all network policy metadata) with ACCOUNT_USAGE.POLICY_REFERENCES (tracks which entities policies are linked to)
  • Filters for only user-level assignments (excludes roles, warehouses, etc.)
  • Returns the policy name, type, assigned user, and timestamps for policy creation/modification
Check Policies for a Specific User

If you only care about one user's applied network policies, tweak the query to target their username:

SELECT
  np.POLICY_NAME,
  np.ALLOWED_IP_LIST,
  np.BLOCKED_IP_LIST,
  np.CREATED_ON
FROM
  ACCOUNT_USAGE.NETWORK_POLICIES np
JOIN
  ACCOUNT_USAGE.POLICY_REFERENCES pr
ON
  np.POLICY_ID = pr.POLICY_ID
WHERE
  pr.REFERENCE_ENTITY_NAME = 'YOUR_TARGET_USER' -- Replace with actual username
  AND pr.REFERENCE_ENTITY_TYPE = 'USER';

This will show you the exact IP rules (allowed/blocked) tied to that user's policies.

View All Network Policies (Including Unassigned)

If you want a full list of every network policy in your account—even those not yet attached to any user—use this simpler query:

SELECT
  POLICY_NAME,
  POLICY_TYPE,
  ALLOWED_IP_LIST,
  BLOCKED_IP_LIST,
  CREATED_ON,
  LAST_ALTERED
FROM
  ACCOUNT_USAGE.NETWORK_POLICIES
ORDER BY
  CREATED_ON DESC;

Important Note on Permissions

To access these ACCOUNT_USAGE views, you'll need either the ACCOUNTADMIN role, or have been granted the MONITOR USAGE privilege by an account admin. If you get permission errors, reach out to your Snowflake account administrator for access.

内容的提问来源于stack exchange,提问作者RJ E2

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 20:39:08