Reference documentation and code samples for the Cloud Spanner V1 Client class Database.
A Cloud Spanner database.
Generated from protobuf messagegoogle.spanner.admin.database.v1.Database
Namespace
Google \ Cloud \ Spanner \ Admin \ Database \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ name
string
Required. The name of the database. Values are of the formprojects/<project>/instances/<instance>/databases/<database>, where<database>is as specified in theCREATE DATABASEstatement. This name can be passed to other API methods to identify the database.
Output only. For databases that are using customer managed encryption, this field contains the encryption configuration for the database. For databases that are using Google default or other types of encryption, this field is empty.
Output only. For databases that are using customer managed encryption, this field contains the encryption information for the database, such as all Cloud KMS key versions that are in use. Theencryption_status' field inside of eachEncryptionInfo` is not populated. For databases that are using Google default or other types of encryption, this field is empty. This field is propagated lazily from the backend. There might be a delay from when a key version is being used and when it appears in this field.
↳ version_retention_period
string
Output only. The period in which Cloud Spanner retains all versions of data for the database. This is the same as the value of version_retention_period database option set usingUpdateDatabaseDdl. Defaults to 1 hour, if not set.
Output only. Earliest timestamp at which older versions of the data can be read. This value is continuously updated by Cloud Spanner and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery.
↳ default_leader
string
Output only. The read-write region which contains the database's leader replicas. This is the same as the value of default_leader database option set using DatabaseAdmin.CreateDatabase or DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
↳ database_dialect
int
Output only. The dialect of the Cloud Spanner Database.
↳ enable_drop_protection
bool
Whether drop protection is enabled for this database. Defaults to false, if not set. For more details, please see how toprevent accidental database deletion.
↳ reconciling
bool
Output only. If true, the database is being updated. If false, there are no ongoing update operations for the database.
getName
Required. The name of the database. Values are of the formprojects/<project>/instances/<instance>/databases/<database>,
where<database>is as specified in theCREATE DATABASEstatement. This name can be passed to other API methods to
identify the database.
Returns
Type
Description
string
setName
Required. The name of the database. Values are of the formprojects/<project>/instances/<instance>/databases/<database>,
where<database>is as specified in theCREATE DATABASEstatement. This name can be passed to other API methods to
identify the database.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getState
Output only. The current database state.
Returns
Type
Description
int
setState
Output only. The current database state.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getCreateTime
Output only. If exists, the time at which the database creation started.
Output only. For databases that are using customer managed encryption, this
field contains the encryption information for the database, such as
all Cloud KMS key versions that are in use. Theencryption_status' field
inside of eachEncryptionInfo` is not populated.
For databases that are using Google default or other types of encryption,
this field is empty.
This field is propagated lazily from the backend. There might be a delay
from when a key version is being used and when it appears in this field.
Output only. For databases that are using customer managed encryption, this
field contains the encryption information for the database, such as
all Cloud KMS key versions that are in use. Theencryption_status' field
inside of eachEncryptionInfo` is not populated.
For databases that are using Google default or other types of encryption,
this field is empty.
This field is propagated lazily from the backend. There might be a delay
from when a key version is being used and when it appears in this field.
Output only. The period in which Cloud Spanner retains all versions of data
for the database. This is the same as the value of version_retention_period
database option set usingUpdateDatabaseDdl.
Defaults to 1 hour, if not set.
Returns
Type
Description
string
setVersionRetentionPeriod
Output only. The period in which Cloud Spanner retains all versions of data
for the database. This is the same as the value of version_retention_period
database option set usingUpdateDatabaseDdl.
Defaults to 1 hour, if not set.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getEarliestVersionTime
Output only. Earliest timestamp at which older versions of the data can be
read. This value is continuously updated by Cloud Spanner and becomes stale
the moment it is queried. If you are using this value to recover data, make
sure to account for the time from the moment when the value is queried to
the moment when you initiate the recovery.
Output only. Earliest timestamp at which older versions of the data can be
read. This value is continuously updated by Cloud Spanner and becomes stale
the moment it is queried. If you are using this value to recover data, make
sure to account for the time from the moment when the value is queried to
the moment when you initiate the recovery.
Output only. The read-write region which contains the database's leader
replicas.
This is the same as the value of default_leader
database option set using DatabaseAdmin.CreateDatabase or
DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
Returns
Type
Description
string
setDefaultLeader
Output only. The read-write region which contains the database's leader
replicas.
This is the same as the value of default_leader
database option set using DatabaseAdmin.CreateDatabase or
DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getDatabaseDialect
Output only. The dialect of the Cloud Spanner Database.
Returns
Type
Description
int
setDatabaseDialect
Output only. The dialect of the Cloud Spanner Database.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getEnableDropProtection
Whether drop protection is enabled for this database. Defaults to false,
if not set. For more details, please see how toprevent accidental
database
deletion.
Returns
Type
Description
bool
setEnableDropProtection
Whether drop protection is enabled for this database. Defaults to false,
if not set. For more details, please see how toprevent accidental
database
deletion.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getReconciling
Output only. If true, the database is being updated. If false, there are no
ongoing update operations for the database.
Returns
Type
Description
bool
setReconciling
Output only. If true, the database is being updated. If false, there are no
ongoing update operations for the database.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Spanner V1 Client - Class Database (1.104.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.104.0 (latest)](/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Database)\n- [1.103.0](/php/docs/reference/cloud-spanner/1.103.0/Admin.Database.V1.Database)\n- [1.102.0](/php/docs/reference/cloud-spanner/1.102.0/Admin.Database.V1.Database)\n- [1.101.0](/php/docs/reference/cloud-spanner/1.101.0/Admin.Database.V1.Database)\n- [1.100.0](/php/docs/reference/cloud-spanner/1.100.0/Admin.Database.V1.Database)\n- [1.98.0](/php/docs/reference/cloud-spanner/1.98.0/Admin.Database.V1.Database)\n- [1.97.0](/php/docs/reference/cloud-spanner/1.97.0/Admin.Database.V1.Database)\n- [1.96.0](/php/docs/reference/cloud-spanner/1.96.0/Admin.Database.V1.Database)\n- [1.95.0](/php/docs/reference/cloud-spanner/1.95.0/Admin.Database.V1.Database)\n- [1.94.0](/php/docs/reference/cloud-spanner/1.94.0/Admin.Database.V1.Database)\n- [1.93.1](/php/docs/reference/cloud-spanner/1.93.1/Admin.Database.V1.Database)\n- [1.92.1](/php/docs/reference/cloud-spanner/1.92.1/Admin.Database.V1.Database)\n- [1.91.0](/php/docs/reference/cloud-spanner/1.91.0/Admin.Database.V1.Database)\n- [1.90.0](/php/docs/reference/cloud-spanner/1.90.0/Admin.Database.V1.Database)\n- [1.89.0](/php/docs/reference/cloud-spanner/1.89.0/Admin.Database.V1.Database)\n- [1.88.0](/php/docs/reference/cloud-spanner/1.88.0/Admin.Database.V1.Database)\n- [1.87.0](/php/docs/reference/cloud-spanner/1.87.0/Admin.Database.V1.Database)\n- [1.86.0](/php/docs/reference/cloud-spanner/1.86.0/Admin.Database.V1.Database)\n- [1.85.0](/php/docs/reference/cloud-spanner/1.85.0/Admin.Database.V1.Database)\n- [1.84.0](/php/docs/reference/cloud-spanner/1.84.0/Admin.Database.V1.Database)\n- [1.83.0](/php/docs/reference/cloud-spanner/1.83.0/Admin.Database.V1.Database)\n- [1.82.0](/php/docs/reference/cloud-spanner/1.82.0/Admin.Database.V1.Database)\n- [1.81.0](/php/docs/reference/cloud-spanner/1.81.0/Admin.Database.V1.Database)\n- [1.80.0](/php/docs/reference/cloud-spanner/1.80.0/Admin.Database.V1.Database)\n- [1.79.0](/php/docs/reference/cloud-spanner/1.79.0/Admin.Database.V1.Database)\n- [1.78.0](/php/docs/reference/cloud-spanner/1.78.0/Admin.Database.V1.Database)\n- [1.77.0](/php/docs/reference/cloud-spanner/1.77.0/Admin.Database.V1.Database)\n- [1.76.1](/php/docs/reference/cloud-spanner/1.76.1/Admin.Database.V1.Database)\n- [1.68.0](/php/docs/reference/cloud-spanner/1.68.0/Admin.Database.V1.Database)\n- [1.67.0](/php/docs/reference/cloud-spanner/1.67.0/Admin.Database.V1.Database)\n- [1.66.0](/php/docs/reference/cloud-spanner/1.66.0/Admin.Database.V1.Database)\n- [1.65.0](/php/docs/reference/cloud-spanner/1.65.0/Admin.Database.V1.Database)\n- [1.64.0](/php/docs/reference/cloud-spanner/1.64.0/Admin.Database.V1.Database)\n- [1.63.2](/php/docs/reference/cloud-spanner/1.63.2/Admin.Database.V1.Database)\n- [1.62.1](/php/docs/reference/cloud-spanner/1.62.1/Admin.Database.V1.Database)\n- [1.61.0](/php/docs/reference/cloud-spanner/1.61.0/Admin.Database.V1.Database)\n- [1.60.0](/php/docs/reference/cloud-spanner/1.60.0/Admin.Database.V1.Database)\n- [1.59.0](/php/docs/reference/cloud-spanner/1.59.0/Admin.Database.V1.Database)\n- [1.58.4](/php/docs/reference/cloud-spanner/1.58.4/Admin.Database.V1.Database)\n- [1.57.0](/php/docs/reference/cloud-spanner/1.57.0/Admin.Database.V1.Database)\n- [1.56.0](/php/docs/reference/cloud-spanner/1.56.0/Admin.Database.V1.Database)\n- [1.55.0](/php/docs/reference/cloud-spanner/1.55.0/Admin.Database.V1.Database)\n- [1.54.2](/php/docs/reference/cloud-spanner/1.54.2/Admin.Database.V1.Database) \nReference documentation and code samples for the Cloud Spanner V1 Client class Database.\n\nA Cloud Spanner database.\n\nGenerated from protobuf message `google.spanner.admin.database.v1.Database`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Spanner \\\\ Admin \\\\ Database \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getName\n\nRequired. The name of the database. Values are of the form\n`projects/\u003cproject\u003e/instances/\u003cinstance\u003e/databases/\u003cdatabase\u003e`,\nwhere `\u003cdatabase\u003e` is as specified in the `CREATE DATABASE`\nstatement. This name can be passed to other API methods to\nidentify the database.\n\n### setName\n\nRequired. The name of the database. Values are of the form\n`projects/\u003cproject\u003e/instances/\u003cinstance\u003e/databases/\u003cdatabase\u003e`,\nwhere `\u003cdatabase\u003e` is as specified in the `CREATE DATABASE`\nstatement. This name can be passed to other API methods to\nidentify the database.\n\n### getState\n\nOutput only. The current database state.\n\n### setState\n\nOutput only. The current database state.\n\n### getCreateTime\n\nOutput only. If exists, the time at which the database creation started.\n\n### hasCreateTime\n\n### clearCreateTime\n\n### setCreateTime\n\nOutput only. If exists, the time at which the database creation started.\n\n### getRestoreInfo\n\nOutput only. Applicable only for restored databases. Contains information\nabout the restore source.\n\n### hasRestoreInfo\n\n### clearRestoreInfo\n\n### setRestoreInfo\n\nOutput only. Applicable only for restored databases. Contains information\nabout the restore source.\n\n### getEncryptionConfig\n\nOutput only. For databases that are using customer managed encryption, this\nfield contains the encryption configuration for the database.\n\nFor databases that are using Google default or other types of encryption,\nthis field is empty.\n\n### hasEncryptionConfig\n\n### clearEncryptionConfig\n\n### setEncryptionConfig\n\nOutput only. For databases that are using customer managed encryption, this\nfield contains the encryption configuration for the database.\n\nFor databases that are using Google default or other types of encryption,\nthis field is empty.\n\n### getEncryptionInfo\n\nOutput only. For databases that are using customer managed encryption, this\nfield contains the encryption information for the database, such as\nall Cloud KMS key versions that are in use. The `encryption_status' field\ninside of each`EncryptionInfo\\` is not populated.\n\nFor databases that are using Google default or other types of encryption,\nthis field is empty.\nThis field is propagated lazily from the backend. There might be a delay\nfrom when a key version is being used and when it appears in this field.\n\n### setEncryptionInfo\n\nOutput only. For databases that are using customer managed encryption, this\nfield contains the encryption information for the database, such as\nall Cloud KMS key versions that are in use. The `encryption_status' field\ninside of each`EncryptionInfo\\` is not populated.\n\nFor databases that are using Google default or other types of encryption,\nthis field is empty.\nThis field is propagated lazily from the backend. There might be a delay\nfrom when a key version is being used and when it appears in this field.\n\n### getVersionRetentionPeriod\n\nOutput only. The period in which Cloud Spanner retains all versions of data\nfor the database. This is the same as the value of version_retention_period\ndatabase option set using\nUpdateDatabaseDdl.\n\nDefaults to 1 hour, if not set.\n\n### setVersionRetentionPeriod\n\nOutput only. The period in which Cloud Spanner retains all versions of data\nfor the database. This is the same as the value of version_retention_period\ndatabase option set using\nUpdateDatabaseDdl.\n\nDefaults to 1 hour, if not set.\n\n### getEarliestVersionTime\n\nOutput only. Earliest timestamp at which older versions of the data can be\nread. This value is continuously updated by Cloud Spanner and becomes stale\nthe moment it is queried. If you are using this value to recover data, make\nsure to account for the time from the moment when the value is queried to\nthe moment when you initiate the recovery.\n\n### hasEarliestVersionTime\n\n### clearEarliestVersionTime\n\n### setEarliestVersionTime\n\nOutput only. Earliest timestamp at which older versions of the data can be\nread. This value is continuously updated by Cloud Spanner and becomes stale\nthe moment it is queried. If you are using this value to recover data, make\nsure to account for the time from the moment when the value is queried to\nthe moment when you initiate the recovery.\n\n### getDefaultLeader\n\nOutput only. The read-write region which contains the database's leader\nreplicas.\n\nThis is the same as the value of default_leader\ndatabase option set using DatabaseAdmin.CreateDatabase or\nDatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.\n\n### setDefaultLeader\n\nOutput only. The read-write region which contains the database's leader\nreplicas.\n\nThis is the same as the value of default_leader\ndatabase option set using DatabaseAdmin.CreateDatabase or\nDatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.\n\n### getDatabaseDialect\n\nOutput only. The dialect of the Cloud Spanner Database.\n\n### setDatabaseDialect\n\nOutput only. The dialect of the Cloud Spanner Database.\n\n### getEnableDropProtection\n\nWhether drop protection is enabled for this database. Defaults to false,\nif not set. For more details, please see how to [prevent accidental\ndatabase\ndeletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).\n\n### setEnableDropProtection\n\nWhether drop protection is enabled for this database. Defaults to false,\nif not set. For more details, please see how to [prevent accidental\ndatabase\ndeletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).\n\n### getReconciling\n\nOutput only. If true, the database is being updated. If false, there are no\nongoing update operations for the database.\n\n### setReconciling\n\nOutput only. If true, the database is being updated. If false, there are no\nongoing update operations for the database."]]