Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article explains how to use management commands to clone an Azure Data Explorer database schema.
- Database Admin permissions
The following steps describe how to clone a database schema using the Azure Data Explorer web UI. Alternatively, you can use the Kusto client libraries to run the same management commands. For more information, see Create an app to run management commands.
From the left menu, select Query.
In the connection pane, select the database whose schema you want to clone.
Run the following command:
.show database schema as csl script with (ShowObfuscatedStrings = true)
This command returns a script of management commands to recreate the database schema. Note the number of returned records, which is used for verification in a later step. For more information, see .show database schema command.
Copy the CSL script output. To do so, select all of the returned rows. Then, either right-click and select Copy or use the Ctrl + C keyboard shortcut.
In the connection pane, select the database where you want to recreate the schema. If necessary, create a database.
Modify the copied script by replacing the original database name with the new database name.
Run the following command, replacing
<CSLScript>
with the script.Note
Select the full command text and then run it. If you don't select the full text, the command will stop at the first empty line in the script.
.execute database script <| <CSLScript>
This command runs the commands from the script, recreating the database schema on the new database. For more information, see .execute database script command.
Verify that the script ran correctly. To do so, check that the number of returned records is the same as the records from the show schema command. Then, scroll to the final command and check that the
Result
column isComplete
. If a failure occurs, troubleshoot and run the command again.Note
You can rerun the script as often as needed without clearing resources from the previous run.