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

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
protoDescriptorsstring (byte)Proto 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

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
projects_instances_databases_get_ddlselectprojectsId, instancesId, databasesIdReturns 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_ddlupdateprojectsId, instancesId, databasesIdUpdates 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.

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
databasesIdstring
instancesIdstring
projectsIdstring

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 projectsId = '{{ projectsId }}' -- required
AND instancesId = '{{ instancesId }}' -- required
AND databasesId = '{{ databasesId }}' -- required;

UPDATE examples

Updates 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.

UPDATE google.spanner.databases_ddl
SET
data__statements = '{{ statements }}',
data__operationId = '{{ operationId }}',
data__protoDescriptors = '{{ protoDescriptors }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND instancesId = '{{ instancesId }}' --required
AND databasesId = '{{ databasesId }}' --required
RETURNING
name,
done,
error,
metadata,
response;