Alias statement

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Alias statements allow you to define an alias for a database, which can be used in the same query.

The alias statement is useful as a shorthand name for a database so it can be referenced using that alias in the same query.

Syntax

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

Learn more about syntax conventions.

Parameters

Name Type Required Description
DatabaseAliasName string ✔️ An existing name or new database alias name. You can escape the name with brackets. For example, ["Name with spaces"].
QueryURI string ✔️ The URI that can be used to run queries or management commands.
DatabaseName string ✔️ The name of the database to give an alias.

Note

  • To get your Query URI, in the Azure portal, go to your cluster's overview page, and then copy the URI.
  • The mapped Query and the mapped database-name must appear inside double-quotes(") or single-quotes(').

Note

  • To get your Query URI, see Copy a KQL database URI.
  • The mapped Query and the mapped database-name must appear inside double-quotes(") or single-quotes(').

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 StormEvents table in the Weather analytics sample data.

First, count the number of records in that table.

StormEvents
| count

Output

Count
59066

Then, give an alias to the Samples database and use that name to check the record count of the StormEvents table.

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

Output

Count
59066

Create an alias name that contains spaces using the bracket syntax.

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

Output

Count
59066