你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Alias statement

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

别名语句允许为数据库定义别名,该别名可用于同一查询。

alias 语句用作数据库的简写名称,因此可以在同一查询中使用该别名引用该语句。

Syntax

alias database DatabaseAliasName= cluster("QueryURI").database("DatabaseName")

Learn more about syntax conventions.

Parameters

Name 类型 Required Description
DatabaseAliasName string ✔️ 现有名称或新的数据库别名。 可以使用括号对名称进行转义。 例如 ["带空格的名称"]。
QueryURI string ✔️ 可用于运行查询或管理命令的 URI。
DatabaseName string ✔️ 要提供别名的数据库的名称。

Note

  • 若要获取查询 URI,请在 Azure 门户中转到群集的概述页,然后复制该 URI。
  • 映射的查询和映射的数据库名称必须出现在双引号(“)或单引号(') 内。

Note

  • 若要获取查询 URI,请参阅 复制 KQL 数据库 URI
  • 映射的查询和映射的数据库名称必须出现在双引号(“)或单引号(') 内。

Examples

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. 可能需要修改示例查询中的表名称以匹配工作区中的表。

首先,计算该表中的记录数。

StormEvents
| count

Output

Count
59066

然后,为 Samples 数据库提供一个别名,并使用该名称检查 StormEvents 表的记录计数。

alias database samplesAlias = cluster("https://help.kusto.windows.net").database("Samples");
database("samplesAlias").StormEvents | count

Output

Count
59066

使用括号语法创建包含空格的别名。

alias database ["Samples Database Alias"] = cluster("https://help.kusto.windows.net").database("Samples");
database("Samples Database Alias").StormEvents | count

Output

Count
59066