Tous les exemples de code Spanner

This page contains code samples for Cloud Spanner. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.

Add NUMERIC column

Update a schema by adding a NUMERIC column.

View in documentation

Add TIMESTAMP column

Update a schema by adding a TIMESTAMP column.

Batch DML

Call multiple SQL statements in a single transaction by using batch DML.

Cancel backup create operation

Cancel a create backup database operation.

Create client with query options

Create a client with query options. The client can then be used to read, write, and run transactions.

View in documentation

Create clients

Create a client that can read, write, and run transactions.

View in documentation

Create STRUCT object array with data

Create an array of STRUCT objects populated with data.

View in documentation

Create STRUCT object with data

Create a STRUCT object populated with data.

View in documentation

Create table with data types

Create a table with example data types.

Create table with TIMESTAMP column

Create a table with a TIMESTAMP column.

Create user-defined STRUCT

Create a user-defined STRUCT.

View in documentation

Dataflow read

Use a SQL query with the Dataflow connector to read data from all the columns and rows in the specified table.

Dataflow read all

Use SQL queries with the Dataflow connector to read data from all available tables in a database.

Dataflow read api

Use the Dataflow connector to read from a database without using a query by specifying a table name and a list of columns.

Dataflow read with transaction

Use the Dataflow connector to read data from multiple tables at the same point in time to ensure data consistency by performing all of the reads in a single transaction.

Dataflow write group

Use the Dataflow connector to write data by using a MutationGroup class to ensure that a group of mutations is applied atomically.

Dataflow write with mutations

Use the Dataflow connector to write data by using mutations.

DML update commit timestamp

Write a commit timestamp by using a DML statement.

Field access on a STRUCT

Query data using field access on a STRUCT.

View in documentation

Field access on nested STRUCT

Query data using field access on a nested STRUCT.

View in documentation

Hibernate generated IDs

Create a hibernate UUID.

Hibernate inheritance

Use hibernate inheritance and UUIDs to save a payment record in a database.

Hibernate table name

Specify a table name by using hibernate.

JDBC batch transaction

Make a batch transaction by using JDBC.

JDBC connection with query options

Set connection query options by using JDBC.

View in documentation

JDBC create table

Create a table by using JDBC.

JDBC insert

Insert data by using JDBC.

JDBC query

Run a query by using JDBC.

JDBC set statement for query options

Use the SET statement to specify query options by using JDBC.

View in documentation

List backup operations

List all create backup operations running on the database and list the percentage complete for each operation.

List backups

List all backups and access backup data using filters and paging.

List database operations

List all operations running on the database and list the percentage complete for each operation.

Mutations update data with NUMERIC

Update data in NUMERIC column by using mutations.

View in documentation

Mutations update data with TIMESTAMP

Update data in a table containing a TIMESTAMP column by using mutations.

Mutations write data for STRUCT queries

Insert data used for STRUCT queries.

Mutations write data types data

Insert data into a table with example data types by using mutations.

Mutations write data with TIMESTAMP column

Write data into a table containing a TIMESTAMP column by using mutations.

Query data with array of STRUCT

Query data by using an array of STRUCT objects.

View in documentation

Query data with index

Query data by using an index.

View in documentation

Query data with STRUCT

Query data by using a STRUCT object.

View in documentation

Query with ARRAY parameter

Query data by using an ARRAY parameter.

Query with BOOL parameter

Query data by using a BOOL parameter.

Query with BYTES parameter

Query data by using a BYTES parameter.

Query with DATE parameter

Query data by using a DATE parameter.

Query with FLOAT parameter

Query data by using a FLOAT parameter.

Query with INT parameter

Query data by using an INT parameter.

Query with NUMERIC parameter

Query data by using a NUMERIC parameter.

View in documentation

Query with query options

Specify query options.

View in documentation

Query with STRING parameter

Query data by using a STRING parameter.

Query with TIMESTAMP parameter

Query data by using a TIMESTAMP parameter.

Read data in parallel

Read data in parallel by dividing the query into smaller pieces, or partitions, and fetching the partitions in parallel.

View in documentation

Set custom timeout and retry

Set custom timeout and retry for request settings.

Update backup

Update a backup by retrieving the expiry time of a backup and extending it.