共用方式為


Database Class

A database resource.

Variables are only populated by the server, and will be ignored when sending a request.

All required parameters must be populated in order to send to Azure.

Inheritance
azure.mgmt.sql.models._models_py3.TrackedResource
Database

Constructor

Database(*, location: str, tags: Dict[str, str] | None = None, sku: Sku | None = None, create_mode: str | CreateMode | None = None, collation: str | None = None, max_size_bytes: int | None = None, sample_name: str | SampleName | None = None, elastic_pool_id: str | None = None, source_database_id: str | None = None, restore_point_in_time: datetime | None = None, source_database_deletion_date: datetime | None = None, recovery_services_recovery_point_id: str | None = None, long_term_retention_backup_resource_id: str | None = None, recoverable_database_id: str | None = None, restorable_dropped_database_id: str | None = None, catalog_collation: str | CatalogCollationType | None = None, zone_redundant: bool | None = None, license_type: str | DatabaseLicenseType | None = None, read_scale: str | DatabaseReadScale | None = None, high_availability_replica_count: int | None = None, secondary_type: str | SecondaryType | None = None, auto_pause_delay: int | None = None, requested_backup_storage_redundancy: str | RequestedBackupStorageRedundancy | None = None, min_capacity: float | None = None, maintenance_configuration_id: str | None = None, is_ledger_on: bool | None = None, **kwargs)

Parameters

Name Description
location
Required
str

Required. Resource location.

tags
Required

A set of tags. Resource tags.

sku
Required
Sku

The 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:


   az sql db list-editions -l <location> -o table
   `

   Get-AzSqlServerServiceObjective -Location <location>
   `.
create_mode
Required

Specifies the mode of database creation.

Default: regular database creation.

Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database.

Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database.

PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.

Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore.

Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time.

RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID.

Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", "RestoreLongTermRetentionBackup", "OnlineSecondary".

collation
Required
str

The collation of the database.

max_size_bytes
Required
<xref:long>

The max size of the database expressed in bytes.

sample_name
Required

The name of the sample schema to apply when creating this database. Possible values include: "AdventureWorksLT", "WideWorldImportersStd", "WideWorldImportersFull".

elastic_pool_id
Required
str

The resource identifier of the elastic pool containing this database.

source_database_id
Required
str

The resource identifier of the source database associated with create operation of this database.

restore_point_in_time
Required

Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database.

source_database_deletion_date
Required

Specifies the time that the database was deleted.

recovery_services_recovery_point_id
Required
str

The resource identifier of the recovery point associated with create operation of this database.

long_term_retention_backup_resource_id
Required
str

The resource identifier of the long term retention backup associated with create operation of this database.

recoverable_database_id
Required
str

The resource identifier of the recoverable database associated with create operation of this database.

restorable_dropped_database_id
Required
str

The resource identifier of the restorable dropped database associated with create operation of this database.

catalog_collation
Required

Collation of the metadata catalog. Possible values include: "DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS".

zone_redundant
Required

Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.

license_type
Required

The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: "LicenseIncluded", "BasePrice".

read_scale
Required

The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Possible values include: "Enabled", "Disabled".

high_availability_replica_count
Required
int

The number of secondary replicas associated with the database that are used to provide high availability.

secondary_type
Required

The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named".

auto_pause_delay
Required
int

Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled.

requested_backup_storage_redundancy
Required

The storage account type to be used to store backups for this database. Possible values include: "Geo", "Local", "Zone".

min_capacity
Required

Minimal capacity that database will always have allocated, if not paused.

maintenance_configuration_id
Required
str

Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur.

is_ledger_on
Required

Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created.

Keyword-Only Parameters

Name Description
location
Required
tags
Required
sku
Required
create_mode
Required
collation
Required
max_size_bytes
Required
sample_name
Required
elastic_pool_id
Required
source_database_id
Required
restore_point_in_time
Required
source_database_deletion_date
Required
recovery_services_recovery_point_id
Required
long_term_retention_backup_resource_id
Required
recoverable_database_id
Required
restorable_dropped_database_id
Required
catalog_collation
Required
zone_redundant
Required
license_type
Required
read_scale
Required
high_availability_replica_count
Required
secondary_type
Required
auto_pause_delay
Required
requested_backup_storage_redundancy
Required
min_capacity
Required
maintenance_configuration_id
Required
is_ledger_on
Required

Variables

Name Description
id
str

Resource ID.

name
str

Resource name.

type
str

Resource type.

kind
str

Kind of database. This is metadata used for the Azure portal experience.

managed_by
str

Resource that manages the database.

status

The status of the database. Possible values include: "Online", "Restoring", "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", "Disabled".

database_id
str

The ID of the database.

creation_date

The creation date of the database (ISO8601 format).

current_service_objective_name
str

The current service level objective name of the database.

requested_service_objective_name
str

The requested service level objective name of the database.

default_secondary_location
str

The default secondary region for this database.

failover_group_id
str

Failover Group resource identifier that this database belongs to.

max_log_size_bytes
<xref:long>

The max log size for this database.

earliest_restore_date

This records the earliest start date and time that restore is available for this database (ISO8601 format).

current_sku
Sku

The name and tier of the SKU.

current_backup_storage_redundancy

The storage account type used to store backups for this database. Possible values include: "Geo", "Local", "Zone".

paused_date

The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready.

resumed_date

The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused.

is_infra_encryption_enabled

Infra encryption is enabled for this database.