CLI Usage
Common gcloud commands for interacting with Spanner. For instructions on how
to install the Google Cloud SDK, see
Install the Google Cloud SDK.
Instances
List Instances
gcloud spanner instances listCreate Instance
# Fixed nodes
gcloud spanner instances create my-instance \
--config=regional-us-central1 \
--description="My Instance" \
--nodes=1
# Autoscaler
gcloud spanner instances create my-autoscaled-instance \
--config=regional-us-central1 \
--description="My Autoscaled Instance" \
--autoscaling-min-nodes=1 \
--autoscaling-max-nodes=3Databases
List Databases
gcloud spanner databases list --instance=my-instanceCreate Database
gcloud spanner databases create my-database --instance=my-instanceExecute Query
gcloud spanner databases execute-sql my-database --instance=my-instance --sql="SELECT 1"Backups
Create Backup
gcloud spanner backups create my-backup \
--instance=my-instance \
--database=my-database \
--retention-period=7dOperations
List Operations
gcloud spanner operations list --instance=my-instance