Redigera

Dela via


Alias statement

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

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

This is useful when you're working with several clusters but want to appear as if you're working on fewer clusters. The alias must be defined according to the following syntax, where clustername and databasename are existing and valid entities.

Syntax

alias database DatabaseAliasName = cluster("https://clustername.kusto.windows.net").database("DatabaseName")

This is useful when you're working with several Eventhouses but want to appear as if you're working on fewer Eventhouses. The alias must be defined according to the following syntax, where Eventhouse and databasename are existing and valid entities.

Syntax

alias database DatabaseAliasName = cluster("serviceURL").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"].
DatabaseName string ✔️ The name of the database to give an alias.

Note

The mapped cluster-uri and the mapped database-name must appear inside double-quotes(") or single-quotes(').

Note

The mapped Eventhouse-uri and the mapped database-name must appear inside double-quotes(") or single-quotes(').

Examples

In the help cluster, there's a Samples database with a StormEvents table.

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