如何审核谁在ABCD数据库IM雪花上进行查询?

发布于 2025-02-11 19:59:24 字数 107 浏览 1 评论 0 原文

具有ABCD数据库。一个用户已在ABCD数据库上执行查询。另一个用户在ABCD数据库上执行了另一个查询。像这样,只要其他用户执行了不同的用户在ABCD数据库上执行查询。需要捕获用户执行时间并执行查询。

Have abcd database. one user has executed query on abcd database. Another user has executed another query on abcd database. Like this whenever different user has executed different user has executed query on abcd database. Need to capture user execution time and who has executed query..etc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

属性 2025-02-18 19:59:24

此信息是从 https://docs.snowflake.com/en /user-guide/access-history.html 基本上是访问历史记录详细信息。另外,可以从Snowflake-查询历史记录 - 您可以使用用户名或任何其他参数查找详细信息的过滤器中检查相同的细节。

This information is gathered from https://docs.snowflake.com/en/user-guide/access-history.html which is basically the access history details. Also, the same detail can be checked from Snowflake - Query History - Filters where you can use username or any other parameter to look up the details.

卸妝后依然美 2025-02-18 19:59:24

您可以使用snowflake.account_usage架构中可用的query_history视图在过去365天内获取查询的完整信息,包括user_name,执行时间等。

请注意,该视图的延迟最多可能为45分钟。

https://docs.snowflake。 com/en/en/sql-reference/account-usage/query_history.html#query-history-view

另外,您可以在过去7天内使用Information_Schema中可用的query_history函数来检索查询信息,并且没有延迟。

请查看以下文档以获取更多信息。

snowflake.com/en/sql-reference/functions/query_history.html#query-history-query-history-by account-usage.html#差异 - account-usage-usage-and-information-schema“ rel =” nofollow noreferrer“> https://docs.snowflake.com/en/sql-reference/sql-reference/account-usage/account-usage.html-usage.html #differences -bet-account-usage-usage-information-schema

You can use Query_history view available in Snowflake.ACCOUNT_USAGE schema to get the complete information of the query within the last 365 days including user_name, execution time, etc

Please note Latency for the view may be up to 45 minutes.

https://docs.snowflake.com/en/sql-reference/account-usage/query_history.html#query-history-view

Also, you can use QUERY_HISTORY function available in information_schema to retrieve query information within the last 7 days and with no latency.

Please review the below documentation for more information.

https://docs.snowflake.com/en/sql-reference/functions/query_history.html#query-history-query-history-by

https://docs.snowflake.com/en/sql-reference/account-usage.html#differences-between-account-usage-and-information-schema

谈情不如逗狗 2025-02-18 19:59:24

您可以使用以下查询(可以根据需要添加列):

     select distinct QH.query_id, QH.USER_NAME,qh.database_name,Qh.start_time, qh.EXECUTION_TIME from 
 "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY" QH
   where  
  -- QH.query_id='' --If you know the query id,use it here
  -- QH.user_name='USERNAME' -- You can filter by user id
  QH.database_name='DBNAME' --you can filter by databasename
  and qh.start_time > '2022-06-29 12:45:36.291'-- you can filter by date
;

如果要跟踪运行查询的IP地址和应用程序,也可以使用以下查询:

select distinct QH.query_id,LH.client_ip, QH.USER_NAME,s.client_application_id,qh.database_name,Qh.start_time, qh.EXECUTION_TIME from snowflake.account_usage.login_history LH 
inner join "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY" QH
on QH.USER_NAME=LH.user_name 
inner join  "SNOWFLAKE"."ACCOUNT_USAGE"."SESSIONS" S on S.session_id=QH.session_id 
and s.LOGIN_EVENT_ID=lh.EVENT_ID
   where  
  -- QH.query_id='' --If you know the query id,use it here
  -- QH.user_name='USERNAME' --If you know the user id,use it here
  QH.database_name='DBNAME' --If you know the DB id,use it here
  and qh.start_time > '2022-06-29 12:45:36.291'-- filter by date as required
  ;
  

You can use below query(you can add the columns as you need):

     select distinct QH.query_id, QH.USER_NAME,qh.database_name,Qh.start_time, qh.EXECUTION_TIME from 
 "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY" QH
   where  
  -- QH.query_id='' --If you know the query id,use it here
  -- QH.user_name='USERNAME' -- You can filter by user id
  QH.database_name='DBNAME' --you can filter by databasename
  and qh.start_time > '2022-06-29 12:45:36.291'-- you can filter by date
;

If you want to track the IP address and application from where query was run, you can use below query as well:

select distinct QH.query_id,LH.client_ip, QH.USER_NAME,s.client_application_id,qh.database_name,Qh.start_time, qh.EXECUTION_TIME from snowflake.account_usage.login_history LH 
inner join "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY" QH
on QH.USER_NAME=LH.user_name 
inner join  "SNOWFLAKE"."ACCOUNT_USAGE"."SESSIONS" S on S.session_id=QH.session_id 
and s.LOGIN_EVENT_ID=lh.EVENT_ID
   where  
  -- QH.query_id='' --If you know the query id,use it here
  -- QH.user_name='USERNAME' --If you know the user id,use it here
  QH.database_name='DBNAME' --If you know the DB id,use it here
  and qh.start_time > '2022-06-29 12:45:36.291'-- filter by date as required
  ;
  

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文