Skip to main content

databases

Creates, updates, deletes, gets or lists a databases resource.

Overview

Namedatabases
TypeResource
Idazure.sql.databases

Fields

The following fields are returned by SELECT queries:

Successfully retrieved the specified database.

NameDatatypeDescription
identityobjectThe Azure Active Directory identity of the database.
kindstringKind of database. This is metadata used for the Azure portal experience.
locationstringResource location.
managedBystringResource that manages the database.
propertiesobjectResource properties.
skuobjectThe database SKU.

The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the Capabilities_ListByLocation REST API or one of the following commands:

azurecli<br /> az sql db list-editions -l &lt;location&gt; -o table<br /> ````<br /> <br /> powershell
Get-AzSqlServerServiceObjective -Location <location>
````
tagsobjectResource tags.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresourceGroupName, serverName, databaseName, subscriptionId$expand, $filterGets a database.
list_by_elastic_poolselectresourceGroupName, serverName, elasticPoolName, subscriptionIdGets a list of databases in an elastic pool.
list_by_serverselectresourceGroupName, serverName, subscriptionId$skipTokenGets a list of databases.
create_or_updateinsertresourceGroupName, serverName, databaseName, subscriptionId, data__locationCreates a new database or updates an existing database.
updateupdateresourceGroupName, serverName, databaseName, subscriptionIdUpdates an existing database.
deletedeleteresourceGroupName, serverName, databaseName, subscriptionIdDeletes the database.
exportexecresourceGroupName, serverName, databaseName, subscriptionId, storageKeyType, storageKey, storageUri, administratorLogin, administratorLoginPasswordExports a database.
failoverexecresourceGroupName, serverName, databaseName, subscriptionIdreplicaTypeFailovers a database.
importexecresourceGroupName, serverName, databaseName, subscriptionId, storageKeyType, storageKey, storageUri, administratorLogin, administratorLoginPasswordImports a bacpac into a new database.
renameexecresourceGroupName, serverName, databaseName, subscriptionId, idRenames a database.
pauseexecresourceGroupName, serverName, databaseName, subscriptionIdPauses a database.
resumeexecresourceGroupName, serverName, databaseName, subscriptionIdResumes a database.
upgrade_data_warehouseexecresourceGroupName, serverName, databaseName, subscriptionIdUpgrades a data warehouse.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
databaseNamestringThe name of the database to be upgraded.
elasticPoolNamestringThe name of the elastic pool.
resourceGroupNamestringThe name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
serverNamestringThe name of the server.
subscriptionIdstringThe subscription ID that identifies an Azure subscription.
$expandstringThe child resources to include in the response.
$filterstringAn OData filter expression that filters elements in the collection.
$skipTokenstring
replicaTypestringThe type of replica to be failed over.

SELECT examples

Gets a database.

SELECT
identity,
kind,
location,
managedBy,
properties,
sku,
tags
FROM azure.sql.databases
WHERE resourceGroupName = '{{ resourceGroupName }}' -- required
AND serverName = '{{ serverName }}' -- required
AND databaseName = '{{ databaseName }}' -- required
AND subscriptionId = '{{ subscriptionId }}' -- required
AND $expand = '{{ $expand }}'
AND $filter = '{{ $filter }}'
;

INSERT examples

Creates a new database or updates an existing database.

INSERT INTO azure.sql.databases (
data__location,
data__tags,
data__sku,
data__identity,
data__properties,
resourceGroupName,
serverName,
databaseName,
subscriptionId
)
SELECT
'{{ location }}' /* required */,
'{{ tags }}',
'{{ sku }}',
'{{ identity }}',
'{{ properties }}',
'{{ resourceGroupName }}',
'{{ serverName }}',
'{{ databaseName }}',
'{{ subscriptionId }}'
RETURNING
identity,
kind,
location,
managedBy,
properties,
sku,
tags
;

DELETE examples

Deletes the database.

DELETE FROM azure.sql.databases
WHERE resourceGroupName = '{{ resourceGroupName }}' --required
AND serverName = '{{ serverName }}' --required
AND databaseName = '{{ databaseName }}' --required
AND subscriptionId = '{{ subscriptionId }}' --required
;

Lifecycle Methods

Exports a database.

EXEC azure.sql.databases.export 
@resourceGroupName='{{ resourceGroupName }}' --required,
@serverName='{{ serverName }}' --required,
@databaseName='{{ databaseName }}' --required,
@subscriptionId='{{ subscriptionId }}' --required
@@json=
'{
"storageKeyType": "{{ storageKeyType }}",
"storageKey": "{{ storageKey }}",
"storageUri": "{{ storageUri }}",
"administratorLogin": "{{ administratorLogin }}",
"administratorLoginPassword": "{{ administratorLoginPassword }}",
"authenticationType": "{{ authenticationType }}",
"networkIsolation": "{{ networkIsolation }}"
}'
;