Clone a custom table in Azure Analytics

156 Views Asked by At

I have a table in Azure Analytics called TestTable_CL, which has a lot of data there.

I want to clone this table to another one, but only the schema, not the data.

How is this possible?

I have tried to run multiple kusto queries in the Query Editor but not successful...

One of them is for example this:

.create table TestTableCopy_CL (schemaof(TestTable_CL))
1

There are 1 best solutions below

1
On

You can use .create table based-on command to clone a table without data.

Syntax:

.create table <new_table_name> based-on <otherTable>

I reproduced this with a sample table in Kusto database.

  • Created a table named Person and inserted data in that.

enter image description here

  • Below Query is written to create a new table person_cloned_table
.create table person_cloned_table based-on Person

enter image description here

  • When new table is queried for data, it has zero row with same schema as table Person

enter image description here

Reference: .create table based-on - Azure Data Explorer | Microsoft Learn