This page summarizes the Spanner CLI supported commands.
SHOW DATABASES;
USE database_name [ROLE role_name];
CREATE DATABASE database_name;
DROP DATABASE database_name;
SHOW TABLES [schema];
SHOW CREATE TABLE table_name;
SHOW COLUMNS FROM table_name;
SHOW INDEX FROM table_name;
CREATE TABLE ...;
ALTER TABLE ...;
DROP TABLE ...;
TRUNCATE TABLE table_name;
CREATE INDEX ...;
DROP INDEX ...;
CREATE ROLE ...;
DROP ROLE ...;
GRANT ...;
REVOKE ...;
SELECT ...;
{ INSERT|UPDATE|DELETE } ...;
PARTITIONED { UPDATE|DELETE } ...;
EXPLAIN SELECT ...;
EXPLAIN {INSERT|UPDATE|DELETE} ...;
EXPLAIN ANALYZE SELECT ...;
EXPLAIN ANALYZE {INSERT|UPDATE|DELETE} ...;
DESCRIBE SELECT ...;
DESCRIBE {INSERT|UPDATE|DELETE} ... THEN RETURN ...;
ANALYZE;
START BATCH DDL;
RUN BATCH;
ABORT BATCH;
BEGIN [RW] [ISOLATION LEVEL {SERIALIZABLE|REPEATABLE READ}]
[PRIORITY {HIGH|MEDIUM|LOW}] [TAG tag_name];
COMMIT;
ROLLBACK;
seconds|RFC 3339-formatted_time}]
[PRIORITY {HIGH|MEDIUM|LOW}] [TAG tag_name];
CLOSE;
EXIT;
BATCH commandsThe Spanner CLI lets you perform DDL operations in batch mode, which groups
multiple DDL statements into a single operation and speeds up schema changes.
The Spanner CLI supports the following BATCH commands:
START BATCH DDL;
This command initiates a DDL batch. All subsequent DDL statements
(for example, CREATE TABLE, ALTER TABLE, DROP INDEX) that you execute
within this session remain in a pending state and aren't applied to the database
immediately.
RUN BATCH;
After executing START BATCH DDL and subsequent DDL statements, use the RUN
BATCH command to send all the pending DDL operations as a single request to
Spanner. This command reduces the overhead associated with
individual DDL statements, leading to faster schema modifications.
ABORT BATCH;
If you decide not to apply the pending DDL changes, use the ABORT BATCH
command. This command discards all DDL statements collected since you issued the
START BATCH DDL command, effectively rolling back the batch and leaving the
database schema unchanged.
The Spanner CLI supports the following transaction SQL commands:
BEGIN [TRANSACTION] [RO] [seconds|RFC 3339-formatted_time ]
[ISOLATION LEVEL {SERIALIZABLE|REPEATABLE READ}]
[PRIORITY {HIGH|MEDIUM|LOW}] [TAG tag_name];
Start a transaction. You can configure these options:
RO)
transaction.Tag: Set transaction tags using the BEGIN command.
BEGIN TAG tag.
The Spanner CLI adds the tag as a transaction tag.
The tag is also used as a request tag within the transaction.BEGIN RO TAG tag.
Because read-only transactions don't support transaction tags,
Spanner adds the tag as a request tag.COMMIT;
Finalize and make permanent all changes in a read-write transaction.
CLOSE;
Close a read-only transaction.
ROLLBACK;
Rollback (undo) a read-write transaction.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-06-09 UTC.