共用方式為


Get-AzureRmSqlDatabase

取得一或多個資料庫。

警告

自 2024 年 2 月 29 日起,AzureRM PowerShell 模組已正式淘汰。 建議使用者從 AzureRM 遷移至 Az PowerShell 模組,以確保持續支援和更新。

雖然 AzureRM 模組可能仍可運作,但不再維護或支援它,但會根據用戶的判斷權和風險放置任何繼續使用。 如需轉換至 Az 模組的指引,請參閱我們的 移轉資源

語法

Get-AzureRmSqlDatabase
   [[-DatabaseName] <String>]
   [-ServerName] <String>
   [-ResourceGroupName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Get-AzureRmSqlDatabase Cmdlet 會從 Azure SQL 資料庫 伺服器取得一或多個 Azure SQL 資料庫。 Azure 上的 SQL Server Stretch Database 服務也支援此 Cmdlet。

範例

範例 1:取得伺服器上的所有資料庫

PS C:\>Get-AzureRmSqlDatabase -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                          : 

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                          :

此命令會取得伺服器上名為 server01 的所有資料庫。

範例 2:依名稱取得伺服器上的資料庫

PS C:\>Get-AzureRmSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02"
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                          :

此命令會從名為 Server01 的伺服器取得名為 Database02 的資料庫。

參數

-Confirm

執行 Cmdlet 之前先提示您確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-DatabaseName

指定要擷取的資料庫名稱。

類型:String
別名:Name
Position:2
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-DefaultProfile

用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶

類型:IAzureContextContainer
別名:AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ResourceGroupName

指定指派資料庫伺服器的資源群組名稱。

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-ServerName

指定指派資料庫之伺服器的名稱。

類型:String
Position:1
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

類型:SwitchParameter
別名:wi
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

String

輸出

AzureSqlDatabaseModel