Skip to main content

databases_ddl

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

Overview

Namedatabases_ddl
TypeResource
Idgoogle.spanner.databases_ddl

Fields

NameDatatypeDescription
protoDescriptorsstringProto descriptors stored in the database. Contains a protobuf-serialized google.protobuf.FileDescriptorSet. For more details, see protobuffer self description.
statementsarrayA list of formatted DDL statements defining the schema of the database specified in the request.

Methods

NameAccessible byRequired ParamsDescription
projects_instances_databases_get_ddlSELECTdatabasesId, instancesId, projectsIdReturns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
projects_instances_databases_update_ddlUPDATEdatabasesId, instancesId, projectsIdUpdates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, indexes, etc. The returned long-running operation will have a name of the format /operations/ and can be used to track execution of the schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.

SELECT examples

Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.

SELECT
protoDescriptors,
statements
FROM google.spanner.databases_ddl
WHERE databasesId = '{{ databasesId }}'
AND instancesId = '{{ instancesId }}'
AND projectsId = '{{ projectsId }}';

UPDATE example

Updates a databases_ddl resource.

/*+ update */
UPDATE google.spanner.databases_ddl
SET
statements = '{{ statements }}',
operationId = '{{ operationId }}',
protoDescriptors = '{{ protoDescriptors }}'
WHERE
databasesId = '{{ databasesId }}'
AND instancesId = '{{ instancesId }}'
AND projectsId = '{{ projectsId }}';