Cloud Spanner is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication for high availability.
- Before you begin
- Samples
- Add and drop new database role
- Backups-cancel
- Copies a source backup
- Backups-create-with-encryption-key
- Backups-create
- Backups-delete
- Backups-get-database-operations
- Backups-get-operations
- Backups-get
- Backups-restore-with-encryption-key
- Backups-restore
- Backups-update
- Backups
- Batch Write
- Batch
- CRUD
- Creates a new database with a specific default leader
- Database-create-with-encryption-key
- Database-create-with-version-retention-period
- Gets the schema definition of an existing database
- Gets the default leader option of an existing database
- Updates the default leader of an existing database
- Updates a Cloud Spanner Database.
- Datatypes
- Runs an execute sql request with directed read options
- Delete using DML returning.
- Insert using DML returning.
- Update using DML returning.
- DML
- Enable fine grained access control
- Get-commit-stats
- List database roles
- Gets the instance config metadata for the configuration nam6
- Creates a new value-storing index
- Creates a new index
- Executes a read-only SQL query using an existing index.
- Reads data using an existing storing index.
- Read data using an existing index.
- Indexing
- Creates a user-managed instance configuration.
- Deletes a user-managed instance configuration.
- Lists the instance configuration operations.
- Updates a user-managed instance configuration.
- Creates a new instance partition
- Creates a instance with autoscaling config.
- Instance-with-processing-units
- Instance
- Json-add-column
- Json-query-parameter
- Json-update-data
- Lists all databases on the selected instance
- Lists all the available instance configs for the selected project.
- Executes request with max commit delay
- Numeric-add-column
- Numeric-query-parameter
- Numeric-update-data
- Adds a column to an existing table in a Spanner PostgreSQL database.
- Showcase the rules for case-sensitivity and case folding for a Spanner PostgreSQL database.
- Creates a PostgreSQL Database.
- Use cast operator to cast from one data type to another in a Spanner PostgreSQL database.
- Execute a batch of DML statements on a Spanner PostgreSQL database.
- Updates data in a table in a Spanner PostgreSQL database.
- Execute a Partitioned DML on a Spanner PostgreSQL database.
- Delete using DML returning on a Spanner PostgreSQL database.
- Insert using DML returning on a Spanner PostgreSQL database.
- Update using DML returning on a Spanner PostgreSQL database.
- Execute a DML statement with parameters on a Spanner PostgreSQL database.
- Calls a server side function on a Spanner PostgreSQL database.
- Creates a new storing index in a Spanner PostgreSQL database.
- Created interleaved table hierarchy using PostgreSQL dialect.
- Showcase how add a jsonb column in a PostgreSQL table.
- Showcase how query data to a jsonb column in a PostgreSQL table.
- Showcase how update data to a jsonb column in a PostgreSQL table.
- Showcase how to work with the PostgreSQL NUMERIC/DECIMAL data type on a Spanner PostgreSQL database.
- Showcases how a Spanner PostgreSQL database orders null values in a query.
- Execute a query with parameters on a Spanner PostgreSQL database.
- Query the information schema metadata in a Spanner PostgreSQL database.
- Alters a sequence in a PostgreSQL database.
- Creates sequence in PostgreSQL database.
- Drops a sequence in PostgreSQL database.
- Proto-query-data
- Creates a new database with a proto column and enum
- Proto-update-data-dml
- Proto-update-data
- Queryoptions
- Quickstart
- Read data with database role
- Sets a request tag for a single query
- Run Batch update with RPC priority
- Run partitioned update with RPC priority
- Create partitions with RPC priority
- Read data with RPC Priority
- Query data with RPC Priority
- Run transaction with RPC priority
- Schema
- Alters a sequence in a GoogleSQL database.
- Creates sequence in GoogleSQL database.
- Drops a sequence in GoogleSQL database.
- Struct
- Alters a table with foreign key delete cascade action
- Creates a table with foreign key delete cascade action
- Drops a foreign key constraint with delete cascade action
- Timestamp
- Executes a read/write transaction with transaction and request tags
- Transaction
Before running the samples, make sure you've followed the steps outlined in Using the client library.
cd samples
npm install
cd ..
View the source code.
Usage:
node add-and-drop-new-database-role.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/backups-cancel.js
View the source code.
Usage:
node spannerCopyBackup <INSTANCE_ID> <COPY_BACKUP_ID> <SOURCE_BACKUP_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/backups-create-with-encryption-key.js
View the source code.
Usage:
node samples/backups-create.js
View the source code.
Usage:
node samples/backups-delete.js
View the source code.
Usage:
node samples/backups-get-database-operations.js
View the source code.
Usage:
node samples/backups-get-operations.js
View the source code.
Usage:
node samples/backups-get.js
View the source code.
Usage:
node samples/backups-restore-with-encryption-key.js
View the source code.
Usage:
node samples/backups-restore.js
View the source code.
Usage:
node samples/backups-update.js
View the source code.
Usage:
node samples/backups.js
View the source code.
Usage:
node batch-write.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/batch.js
View the source code.
Usage:
node samples/crud.js
View the source code.
Usage:
node database-create-with-default-leader.js <INSTANCE_ID> <DATABASE_ID> <DEFAULT_LEADER> <PROJECT_ID>
View the source code.
Usage:
node samples/database-create-with-encryption-key.js
View the source code.
Usage:
node samples/database-create-with-version-retention-period.js
View the source code.
Usage:
node database-get-ddl.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node database-get-default-leader.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node database-update-default-leader.js <INSTANCE_ID> <DATABASE_ID> <DEFAULT_LEADER> <PROJECT_ID>
View the source code.
Usage:
node database-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/datatypes.js
View the source code.
Usage:
node directed-reads.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node dml-returning-delete.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node dml-returning-insert.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node dml-returning-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/dml.js
View the source code.
Usage:
node enable-fine-grained-access.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/get-commit-stats.js
View the source code.
Usage:
node get-database-roles.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node get-instance-config.js <PROJECT_ID>
View the source code.
Usage:
node createStoringIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node createIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node queryDataWithIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID> <START_TITLE> <END_TITLE>
View the source code.
Usage:
node readDataWithStoringIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node readDataWithIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/indexing.js
View the source code.
Usage:
node instance-config-create <INSTANCE_CONFIG_ID> <BASE_INSTANCE_CONFIG_ID> <PROJECT_ID>
View the source code.
Usage:
node instance-config-delete <INSTANCE_CONFIG_ID> <PROJECT_ID>
View the source code.
Usage:
node instance-config-get-operations <PROJECT_ID>
View the source code.
Usage:
node instance-config-update <INSTANCE_CONFIG_ID> <PROJECT_ID>
View the source code.
Usage:
node instance-partition-create.js <INSTANCE_ID> <INSTANCE_PARTITION_ID> <PROJECT_ID>
View the source code.
Usage:
node instance-with-autoscaling-config.js <INSTANCE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/instance-with-processing-units.js
View the source code.
Usage:
node samples/instance.js
View the source code.
Usage:
node samples/json-add-column.js
View the source code.
Usage:
node samples/json-query-parameter.js
View the source code.
Usage:
node samples/json-update-data.js
View the source code.
Usage:
node list-databases.js <INSTANCE_ID> <PROJECT_ID>
View the source code.
Usage:
node list-instance-configs.js <PROJECT_ID>
View the source code.
Usage:
node max-commit-delay.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/numeric-add-column.js
View the source code.
Usage:
node samples/numeric-query-parameter.js
View the source code.
Usage:
node samples/numeric-update-data.js
View the source code.
Usage:
node pg-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-case-sensitivity.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-database-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-datatypes-casting.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-batch.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-getting-started-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-partitioned.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-returning-delete.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-returning-insert.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-returning-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-dml-with-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-functions.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-index-create-storing.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-interleaving.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-jsonb-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-jsonb-query-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-jsonb-update-data.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
Showcase how to work with the PostgreSQL NUMERIC/DECIMAL data type on a Spanner PostgreSQL database.
View the source code.
Usage:
node ppg-numeric-data-type.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-ordering-nulls.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-query-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-schema-information.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-sequence-alter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-sequence-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node pg-sequence-drop.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/proto-query-data.js
View the source code.
Usage:
node proto-type-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/proto-update-data-dml.js
View the source code.
Usage:
node samples/proto-update-data.js
View the source code.
Usage:
node samples/queryoptions.js
View the source code.
Usage:
node samples/quickstart.js
View the source code.
Usage:
node read-data-with-database-role.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node request-tag.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-batch-dml.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-partitioned-dml.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-query-partitions.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-read.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-run.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node rpc-priority-transaction.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/schema.js
View the source code.
Usage:
node sequence-alter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node sequence-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node sequence-drop.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/struct.js
View the source code.
Usage:
node table-alter-with-foreign-key-delete-cascade.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node table-create-with-foreign-key-delete-cascade.js.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node table-drop-foreign-key-constraint-delete-cascade.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/timestamp.js
View the source code.
Usage:
node transaction-tag.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>
View the source code.
Usage:
node samples/transaction.js