הערה
גישה לעמוד זה דורשת אישור. אתה יכול לנסות להיכנס או לשנות תיקיות.
גישה לעמוד זה דורשת אישור. אתה יכול לנסות לשנות מדריכים.
Applies to: ✅ SQL database in Microsoft Fabric
You can use the Fabric Command Line Interface (CLI) to create SQL databases in Fabric. The Fabric CLI (fab) is a fast, file‑system‑inspired command‑line interface for Microsoft Fabric.
This article and sample scripts demonstrate the basic Fabric CLI commands that can be used to deploy a Fabric SQL database.
Prerequisites
Before you begin:
You need an existing Fabric capacity. If you don't, start a Fabric trial.
You can use an existing workspace or create a new Fabric workspace.
You must be a member of the Admin or Member roles for the workspace to create a SQL database.
Make sure Python version 3.10, 3.11, or 3.12 is installed on your machine. Python should be accessible from your terminal, via the
PATHenvironment variable.Install Fabric CLI on your machine with the following command. If you see a message about updating the
PATHin the output of the installer, fix that before proceeding or subsequent steps can fail.pip install ms-fabric-cli
Create a new SQL database with Fabric CLI
Sign in to Microsoft Fabric. Open a command prompt and run the following command:
fab auth loginFollow the prompts to authenticate using your Microsoft account with access to your Fabric workspace.
Run the following command to create a new SQL database:
- Replace
<workspacename>with the name of the workspace where you want to create the SQL database. - Replace
<databasename>with the name that you want to use for your new SQL database.
fab create <workspacename>.Workspace/<databasename>.SQLDatabase- Replace
Verify the new SQL database in your workspace with the following command:
- Replace
<workspacename>with the name of the workspace where you want to create the SQL database.
fab ls <workspacename>.WorkspaceThe
fab lscommand displays a list of all items in the workspace, including your new SQL database.- Replace
Database collation
By default, the database is created with the case-insensitive collation SQL_Latin1_General_CP1_CI_AS.
Database collation can't be modified after creation, though collations on individual columns are supported.
When you create the database with the Fabric CLI, you can call the Fabric API directly with the fab api set of commands. Specify the desired workspace, new database name and description, and desired collation in the parameters.
Currently, the fab cli command is necessary to create a database with a non-default collation. The syntax is similar, for example:
fab api workspaces/<workspace unique ID>/sqldatabases -X post -H "Content-Type=application/json" -i "{\"displayName\": \"<new database name>\", \"description\": \"<new database description>\", \"creationPayload\":{\"collation\": \"Latin1_General_100_BIN2_UTF8\",\"creationMode\": \"new\"}}"
This example creates a new database in the workspace with the unique ID workspace unique ID, with a name <new database name>, description <new database description>, and the collation Latin1_General_100_BIN2_UTF8.