.create table based-on command

Applies to: ✅ Microsoft FabricAzure Data Explorer

Creates a new empty table based on an existing table. This command must run in the context of a specific database.

Note

All properties of the source table are copied to the new table, with the following exceptions:

Permissions

You must have at least Database Admin permissions to run this command.

Syntax

.create table tableName based-on otherTable [ifnotexists] [with (propertyName = propertyValue [, ...])]

Learn more about syntax conventions.

Parameters

Name Type Required Description
ifnotexists string If specified, the table will only be created if it doesn't already exist.
tableName string ✔️ The name of the table to create. The case-senestive name must be unique in the database.
otherTable string ✔️ The name of an existing table to use as the source for the columns, docstring, and folder of the table being created.
propertyName, propertyValue string A comma-separated list of key-value property pairs. See supported properties.

Supported properties

Name Type Description
docstring string Free text describing the entity to be added. This string is presented in various UX settings next to the entity names. The default value is Created based on <tableName>.
folder string The name of the folder where to add the table. The default is the same folder as tableName.

Returns

This command returns the new table's schema in JSON format, similar to running the following command:

.show table MyLogs schema as json

Note

  • If the table already exists:
    • If ifnotexists flag is specified, the command is ignored (no change applied).
    • If ifnotexists flag is NOT specified, an error is returned.

Example

.create table MyLogs_Temp based-on MyLogs with (folder="TempTables")