Get-AzSqlDatabase
取得一或多個資料庫。
語法
Default (預設值)
Get-AzSqlDatabase
[[-DatabaseName] <String>]
[-ExpandKeyList]
[-KeysFilter <String>]
[-ServerName] <String>
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
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
此指令會取得名為 server01 的伺服器上以 “database” 開頭的所有資料庫。
範例 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 金鑰的資料庫,並篩選為「目前」
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 金鑰的資料庫,並將篩選器設定為「目前」
範例 7:取得設定慣用記憶體保護區類型為 VBS 的資料庫
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 記憶體保護區的資料庫
參數
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 參見 |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-DatabaseName
指定要擷取的資料庫名稱。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
| 別名: | 名稱 |
參數集
(All)
| Position: | 2 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-DefaultProfile
用來與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶
參數屬性
| 類型: | IAzureContextContainer |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | AzContext, AzureRmContext, AzureCredential |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-ExpandKeyList
用來檢視資料庫中所有 AKV 金鑰的旗標。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-KeysFilter
取得 AKV 金鑰的時間戳記篩選器
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-ResourceGroupName
指定指派資料庫伺服器的資源群組名稱。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-ServerName
指定指派資料庫之伺服器名稱。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | 1 |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 指令未執行。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 威斯康辛 |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。