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

如何使用KQL查询同时包含指定多列的所有数据表?

跨表多列条件查询的KQL语句

查找同时包含指定多列的表

要找出同时存在Customer_ID和mail列的所有表,可以利用Kusto的系统表sys.columns实现,它存储了集群中所有表的列元数据。

对应的KQL语句如下:

sys.columns
| where name in ("Customer_ID", "mail")
| summarize target_column_count = dcount(name) by table_name
| where target_column_count == 2
| project table_name

语句逻辑说明

  • sys.columns:获取所有表的列信息
  • where name in ("Customer_ID", "mail"):筛选出包含目标列的记录
  • summarize target_column_count = dcount(name) by table_name:按表名分组,统计每个表中包含的目标不同列的数量(dcount确保重复列名只计数一次)
  • where target_column_count == 2:仅保留同时包含两个目标列的表
  • project table_name:输出符合条件的表名

扩展:查找包含任意指定列的表

如果需要查询包含Customer_ID或mail中任意一列的表,只需去掉统计数量的过滤条件即可:

sys.columns
| where name in ("Customer_ID", "mail")
| summarize target_column_count = dcount(name) by table_name
| project table_name, target_column_count

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 16:09:52