在 Azure SQL 数据库中管理弹性池Manage elastic pools in Azure SQL Database

适用于: Azure SQL 数据库

使用弹性池,可以确定弹性池处理其数据库工作负荷所需的资源量,以及每个共用数据库的资源量。With an elastic pool, you determine the amount of resources that the elastic pool requires to handle the workload of its databases, and the amount of resources for each pooled database.

Azure 门户Azure portal

可在一个位置找到所有池设置:“配置池”边栏选项卡。All pool settings can be found in one place: the Configure pool blade. 若要转到该位置,请在 Azure 门户中找到所需的弹性池,然后在边栏选项卡顶部,或者在左侧资源菜单中单击“配置池”。To get here, find an elastic pool in the Azure portal and click Configure pool either from the top of the blade or from the resource menu on the left.

在此处,可以进行以下任意更改组合,并将所有这些更改保存到一个批处理文件中:From here you can make any combination of the following changes and save them all in one batch:

  1. 更改池的服务层级Change the service tier of the pool
  2. 缩放性能(DTU 或 vCore)和存储Scale the performance (DTU or vCores) and storage up or down
  3. 在池中添加或删除数据库Add or remove databases to/from the pool
  4. 为池中的数据库设置最小(保证)和最大性能限制Set a min (guaranteed) and max performance limit for the databases in the pools
  5. 检查成本摘要,以查看做出新选择后帐单发生的任何更改Review the cost summary to view any changes to your bill as a result of your new selections




本文已经过更新,以便使用 Azure Az PowerShell 模块。This article has been updated to use the Azure Az PowerShell module. 若要与 Azure 交互,建议使用的 PowerShell 模块是 Az PowerShell 模块。The Az PowerShell module is the recommended PowerShell module for interacting with Azure. 若要开始使用 Az PowerShell 模块,请参阅安装 Azure PowerShellTo get started with the Az PowerShell module, see Install Azure PowerShell. 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 AzTo learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.


PowerShell Azure 资源管理器模块仍受 Azure SQL 数据库的支持,但所有未来的开发都是针对 Az.Sql 模块的。The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. 若要了解这些 cmdlet,请参阅 AzureRM.SqlFor these cmdlets, see AzureRM.Sql. Az 模块和 AzureRm 模块中的命令参数大体上是相同的。The arguments for the commands in the Az module and in the AzureRm modules are substantially identical.

若要使用 Azure PowerShell 创建并管理 SQL 数据库弹性池和共用数据库,请使用以下 PowerShell cmdlet。To create and manage SQL Database elastic pools and pooled databases with Azure PowerShell, use the following PowerShell cmdlets. 如果需要安装或升级 PowerShell,请参阅安装 Azure PowerShell 模块If you need to install or upgrade PowerShell, see Install Azure PowerShell module. 若要创建和管理弹性池的服务器,请参阅创建和管理服务器To create and manage the servers for an elastic pool, see Create and manage servers. 若要创建和管理防火墙规则,请参阅使用 PowerShell 创建和管理防火墙规则To create and manage firewall rules, see Create and manage firewall rules using PowerShell.

CmdletCmdlet 说明Description
New-AzSqlElasticPoolNew-AzSqlElasticPool 创建弹性池。Creates an elastic pool.
Get-AzSqlElasticPoolGet-AzSqlElasticPool 获取弹性池及其属性值。Gets elastic pools and their property values.
Set-AzSqlElasticPoolSet-AzSqlElasticPool 修改弹性池的属性。例如,使用“StorageMB”属性修改弹性池的最大存储。Modifies properties of an elastic pool For example, use the StorageMB property to modify the max storage of an elastic pool.
Remove-AzSqlElasticPoolRemove-AzSqlElasticPool 删除弹性池。Deletes an elastic pool.
Get-AzSqlElasticPoolActivityGet-AzSqlElasticPoolActivity 获取弹性池的运行状态Gets the status of operations on an elastic pool
New-AzSqlDatabaseNew-AzSqlDatabase 在现有池中创建新数据库或将其创建为单一数据库。Creates a new database in an existing pool or as a single database.
Get-AzSqlDatabaseGet-AzSqlDatabase 获取一个或多个数据库。Gets one or more databases.
Set-AzSqlDatabaseSet-AzSqlDatabase 设置数据库的属性,将现有数据库移入、移出弹性池或在其之间移动。Sets properties for a database, or moves an existing database into, out of, or between elastic pools.
Remove-AzSqlDatabaseRemove-AzSqlDatabase 删除数据库。Removes a database.


使用门户或每次只能创建一个单一数据库的 PowerShell cmdlet 在弹性池中创建多个数据库可能需要一段时间。Creation of many databases in an elastic pool can take time when done using the portal or PowerShell cmdlets that create only a single database at a time. 若要自动创建到弹性池中,请参阅 CreateOrUpdateElasticPoolAndPopulateTo automate creation into an elastic pool, see CreateOrUpdateElasticPoolAndPopulate.

Azure CLIAzure CLI

若要使用 Azure CLI 创建和管理 SQL 数据库弹性池,请使用下面的 Azure CLI SQL 数据库命令。To create and manage SQL Database elastic pools with the Azure CLI, use the following Azure CLI SQL Database commands. 在 macOS、 Linux 或 Windows 上安装 CLI。Install it on macOS, Linux, or Windows.

CmdletCmdlet 说明Description
az sql elastic-pool createaz sql elastic-pool create 创建弹性池。Creates an elastic pool.
az sql elastic-pool listaz sql elastic-pool list 返回服务器中弹性池的列表。Returns a list of elastic pools in a server.
az sql elastic-pool list-dbsaz sql elastic-pool list-dbs 返回弹性池中数据库的列表。Returns a list of databases in an elastic pool.
az sql elastic-pool list-editionsaz sql elastic-pool list-editions 还包括可用的池 DTU 设置、存储限制和每数据库设置。Also includes available pool DTU settings, storage limits, and per database settings. 为了降低冗长,默认情况下会隐藏附加的存储限制以及每数据库设置。In order to reduce verbosity, additional storage limits and per database settings are hidden by default.
az sql elastic-pool updateaz sql elastic-pool update 更新弹性池。Updates an elastic pool.
az sql elastic-pool deleteaz sql elastic-pool delete 删除弹性池。Deletes the elastic pool.

Transact-SQL (T-SQL)Transact-SQL (T-SQL)

若要使用 Transact-SQL 在现有弹性池内创建和移动数据库或者返回有关 SQL 数据库弹性池的信息,请使用以下 T-SQL 命令。To create and move databases within existing elastic pools or to return information about an SQL Database elastic pool with Transact-SQL, use the following T-SQL commands. 可以使用 Azure 门户、SQL Server Management StudioVisual Studio Code 或可以连接到服务器并传递 Transact-SQL 命令的任何其他程序来发出这些命令。You can issue these commands using the Azure portal, SQL Server Management Studio, Visual Studio Code, or any other program that can connect to a server and pass Transact-SQL commands. 若要使用 T-SQL 创建和管理防火墙规则,请参阅使用 Transact-SQL 管理防火墙规则To create and manage firewall rules using T-SQL, see Manage firewall rules using Transact-SQL.


无法使用 Transact-SQL 创建、更新或删除 Azure SQL 数据库弹性池。You cannot create, update, or delete an Azure SQL Database elastic pool using Transact-SQL. 可以在弹性池中添加或删除数据库,并且可以使用 DMV 返回有关现有弹性池的信息。You can add or remove databases from an elastic pool, and you can use DMVs to return information about existing elastic pools.

命令Command 说明Description
CREATE DATABASE(Azure SQL 数据库)CREATE DATABASE (Azure SQL Database) 在现有池中创建新数据库或将其创建为单一数据库。Creates a new database in an existing pool or as a single database. 必须连接到 master 数据库,才能新建数据库。You must be connected to the master database to create a new database.
ALTER DATABASE(Azure SQL 数据库)ALTER DATABASE (Azure SQL Database) 将数据库移入、移出弹性池或在其之间移动。Move a database into, out of, or between elastic pools.
DROP DATABASE (Transact-SQL)DROP DATABASE (Transact-SQL) 删除数据库。Deletes a database.
sys.elastic_pool_resource_stats(Azure SQL 数据库)sys.elastic_pool_resource_stats (Azure SQL Database) 返回服务器中所有弹性池的资源使用率统计信息。Returns resource usage statistics for all the elastic pools on a server. 对于每个弹性池,报告窗口每 15 秒就会提供一行(每分钟四行)。For each elastic pool, there is one row for each 15 second reporting window (four rows per minute). 这包括池中所有数据库的 CPU、IO、日志和存储消耗以及并发的请求/会话利用率。This includes CPU, IO, Log, storage consumption and concurrent request/session utilization by all databases in the pool.
sys.database_service_objectives(Azure SQL 数据库)sys.database_service_objectives (Azure SQL Database) 返回 SQL 数据库或 Azure Synapse Analytics 中数据库的版本(服务层级)、服务目标(定价层)和弹性池名称(若有)。Returns the edition (service tier), service objective (pricing tier), and elastic pool name, if any, for a database in SQL Database or Azure Synapse Analytics. 如果登录到服务器中的 master 数据库,则将返回有关所有数据库的信息。If logged on to the master database in a server, returns information on all databases. 对于 Azure Synapse Analytics,必须连接到 master 数据库。For Azure Synapse Analytics, you must be connected to the master database.


若要创建和管理 SQL 数据库弹性池和共用数据库,请使用这些 REST API 请求。To create and manage SQL Database elastic pools and pooled databases, use these REST API requests.

命令Command 说明Description
弹性池 - 创建或更新Elastic pools - Create or update 创建新弹性池或更新现有的弹性池。Creates a new elastic pool or updates an existing elastic pool.
弹性池 - 删除Elastic pools - Delete 删除弹性池。Deletes the elastic pool.
弹性池 - 获取Elastic pools - Get 获取弹性池。Gets an elastic pool.
弹性池 - 按服务器列出Elastic pools - List by server 返回服务器中弹性池的列表。Returns a list of elastic pools in a server.
弹性池 - 更新Elastic pools - Update 更新现有的弹性池。Updates an existing elastic pool.
弹性池活动Elastic pool activities 返回弹性池活动。Returns elastic pool activities.
弹性池数据库活动Elastic pool database activities 返回弹性池内数据库上的活动。Returns activity on databases inside of an elastic pool.
数据库 - 创建或更新Databases - Create or update 创建新数据库或更新现有数据库。Creates a new database or updates an existing database.
数据库 - 获取Databases - Get 获取数据库。Gets a database.
数据库 - 按弹性池列出Databases - List by elastic pool 返回弹性池中数据库的列表。Returns a list of databases in an elastic pool.
数据库 - 按服务器列出Databases - List by server 返回服务器中的数据库列表。Returns a list of databases in a server.
数据库 - 更新Databases - Update 更新现有的数据库。Updates an existing database.