你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Get-AzSqlDatabase

获取一个或多个数据库。

语法

Get-AzSqlDatabase
   [[-DatabaseName] <String>]
   [-ExpandKeyList]
   [-KeysFilter <String>]
   [-ServerName] <String>
   [-ResourceGroupName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

Get-AzSqlDatabase cmdlet 从 Azure SQL 数据库 服务器获取一个或多个 Azure SQL 数据库。 Azure 上的 SQL Server Stretch Database 服务也支持此 cmdlet。

示例

示例 1:获取服务器上的所有数据库

Get-AzSqlDatabase -ResourceGroupName "resourcegroup01" -ServerName "server01"

ResourceGroupName				         : resourcegroup01
ServerName						           : server01
DatabaseName					           : master
Location						             : Central US
DatabaseId						           : a2a7f2db-7526-4d86-a7b2-36276ee10dc6
Edition							             : None
CollationName					           : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				         : 
MaxSizeBytes					           : 5368709120
Status							             : Online
CreationDate					           : 7/3/2015 7:32:44 AM
CurrentServiceObjectiveId		     : c99ac918-dbea-463f-a475-16ec020fdc12
CurrentServiceObjectiveName		   : System1
RequestedServiceObjectiveId		   : c99ac918-dbea-463f-a475-16ec020fdc12
RequestedServiceObjectiveName	   : 
ElasticPoolName					         : 
EarliestRestoreDate				       : 
Tags							               :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo

ResourceGroupName				         : resourcegroup01
ServerName						           : server01
DatabaseName                     : database01
Location						             : Central US
DatabaseId						           : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition							             : Standard
CollationName					           : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				         : 
MaxSizeBytes					           : 268435456000
Status							             : Online
CreationDate					           : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		     : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		   : S0
RequestedServiceObjectiveId		   : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	   : 
ElasticPoolName					         : 
EarliestRestoreDate				       : 
Tags							               :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo

此命令获取名为 server01 的服务器中的所有数据库。

示例 2:按名称获取服务器上的数据库

Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02"

ResourceGroupName				         : resourcegroup01
ServerName						           : server01
DatabaseName					           : database02
Location						             : Central US
DatabaseId						           : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition							             : Standard
CollationName					           : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				         : 
MaxSizeBytes					           : 268435456000
Status							             : Online
CreationDate					           : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		     : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		   : S0
RequestedServiceObjectiveId		   : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	   : 
ElasticPoolName                  : 
EarliestRestoreDate				       : 
Tags							               :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo

此命令从名为 Server01 的服务器获取名为 Database02 的数据库。

示例 3:使用筛选获取服务器上的所有数据库

Get-AzSqlDatabase -ResourceGroupName "resourcegroup01" -ServerName "server01" -DatabaseName "database*"

ResourceGroupName				         : resourcegroup01
ServerName						           : server01
DatabaseName					           : database01
Location						             : Central US
DatabaseId						           : a2a7f2db-7526-4d86-a7b2-36276ee10dc6
Edition							             : None
CollationName				             : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				         : 
MaxSizeBytes					           : 5368709120
Status							             : Online
CreationDate					           : 7/3/2015 7:32:44 AM
CurrentServiceObjectiveId		     : c99ac918-dbea-463f-a475-16ec020fdc12
CurrentServiceObjectiveName		   : System1
RequestedServiceObjectiveId		   : c99ac918-dbea-463f-a475-16ec020fdc12
RequestedServiceObjectiveName	   : 
ElasticPoolName					         : 
EarliestRestoreDate				       : 
Tags							               : 
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo

ResourceGroupName				         : resourcegroup01
ServerName						           : server01
DatabaseName					           : database02
Location                         : Central US
DatabaseId					             : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition						               : Standard
CollationName					           : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				         : 
MaxSizeBytes					           : 268435456000
Status							             : Online
CreationDate					           : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		     : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		   : S0
RequestedServiceObjectiveId		   : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	   : 
ElasticPoolName					         : 
EarliestRestoreDate				       : 
Tags                             :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo

此命令获取以“database”开头的服务器中名为 server01 的所有数据库。

示例 4:使用 expand keys 参数获取服务器上具有 TDE AKV 密钥的数据库。

Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02" -ExpandKeyList

ResourceGroupName				 : resourcegroup01
ServerName						 : server01
DatabaseName					 : database02
Location						 : Central US
DatabaseId						 : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition							 : Standard
CollationName					 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				 : 
MaxSizeBytes					 : 268435456000
Status							 : Online
CreationDate					 : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		 : S0
RequestedServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	 : 
ElasticPoolName                  : 
EarliestRestoreDate				 : 
Tags							 :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo
Identity                         : Microsoft.Azure.Management.Sql.Models.DatabaseIdentity
EncryptionProtector              : https://contoso.vault.azure.net/keys/contosokey/01234567890123456789012345678901
Keys                             : {[https://contoso.vault.azure.net/keys/contosokey/01234567890123456789012345678901, Microsoft.Azure.Management.Sql.Models.DatabaseKey], 
                                    [https://contoso.vault.azure.net/keys/contosokey2/09876543210987654321098765432109, Microsoft.Azure.Management.Sql.Models.DatabaseKey]}
FederatedClientId                :

此命令获取在数据库上配置的所有 TDE AKV 密钥。

示例 5:使用扩展键获取服务器上具有 TDE AKV 密钥的数据库,并按日期进行筛选

Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02" -ExpandKeyList -KeysFilter "1/13/2022"

ResourceGroupName				 : resourcegroup01
ServerName						 : server01
DatabaseName					 : database02
Location						 : Central US
DatabaseId						 : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition							 : Standard
CollationName					 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				 : 
MaxSizeBytes					 : 268435456000
Status							 : Online
CreationDate					 : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		 : S0
RequestedServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	 : 
ElasticPoolName                  : 
EarliestRestoreDate				 : 
Tags							 :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo
Identity                         : Microsoft.Azure.Management.Sql.Models.DatabaseIdentity
EncryptionProtector              : https://contoso.vault.azure.net/keys/contosokey/01234567890123456789012345678901
Keys                             : {[https://contoso.vault.azure.net/keys/contosokey/01234567890123456789012345678901, Microsoft.Azure.Management.Sql.Models.DatabaseKey], 
                                    [https://contoso.vault.azure.net/keys/contosokey2/09876543210987654321098765432109, Microsoft.Azure.Management.Sql.Models.DatabaseKey]}
FederatedClientId                :

此命令获取使用 TDE CMK 密钥配置的数据库

示例 6:使用扩展键获取服务器上具有 TDE AKV 密钥的数据库,并筛选为“current”

Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02" -ExpandKeyList -KeysFilter "current"

ResourceGroupName				 : resourcegroup01
ServerName						 : server01
DatabaseName					 : database02
Location						 : Central US
DatabaseId						 : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition							 : Standard
CollationName					 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation				 : 
MaxSizeBytes					 : 268435456000
Status							 : Online
CreationDate					 : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName		 : S0
RequestedServiceObjectiveId		 : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName	 : 
ElasticPoolName                  : 
EarliestRestoreDate				 : 
Tags							 :
CurrentBackupStorageRedundancy	 : Geo
RequestedBackupStorageRedundancy : Geo
Identity                         : Microsoft.Azure.Management.Sql.Models.DatabaseIdentity
EncryptionProtector              : https://contoso.vault.azure.net/keys/contosokey/01234567890123456789012345678901
Keys                             : 
FederatedClientId                :

此命令获取使用 TDE CMK 密钥配置的数据库,其中筛选器为“current”

示例 7:获取配置为 VBS 的首选 enclave 类型的数据库

Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02"

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database02
Location                      : Central US
DatabaseId                    : 34d9d561-42a7-484e-bf05-62ddef8000ab
Edition                       : GeneralPurpose
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 268435456000
Status                        : Online
CreationDate                  : 8/26/2015 10:04:29 PM
CurrentServiceObjectiveName   : GP_Gen5_2
RequestedServiceObjectiveName :
ElasticPoolName               :
EarliestRestoreDate           :
LicenseType                   : LicenseIncluded
Tags                          :
EnableLedger                  : False
PreferredEnclaveType          : VBS

此命令获取配置有 VBS enclave 的数据库

参数

-Confirm

提示你在运行 cmdlet 之前进行确认。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatabaseName

指定要检索的数据库的名称。

Type:String
Aliases:Name
Position:2
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:True

-DefaultProfile

用于与 azure 通信的凭据、帐户、租户和订阅

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExpandKeyList

用于查看数据库中所有 AKV 密钥的标志。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeysFilter

用于获取 AKV 密钥的时间戳筛选器

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

指定为其分配数据库服务器的资源组的名称。

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ServerName

指定为数据库分配的服务器的名称。

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

输入

String

输出

AzureSqlDatabaseModel