Creating instance through command
gcloud spanner instances create banking-instance-2 \\
--config=regional-us-west1 \\
--description="Banking Instance 2" \\
--nodes=2
List all instances
gcloud spanner instances list
Create database
gcloud spanner databases create pets-db
--instance=test-spanner-instance
--database-dialect=GOOGLE_STANDARD_SQL
--ddl-file=./pets-db-schema.sql
Modify number of nodes to instance
gcloud spanner instances update banking-instance-2 --nodes=1
gcloud spanner databases delete pets-db --instance=test-spanner-instance
gcloud spanner instances delete test-spanner-instance --quiet
When monitoring Spanner instances, CPU utilization is the primary metric to watch
owner_uuid=$(cat /proc/sys/kernel/random/uuid)
pet_uuid=$(cat /proc/sys/kernel/random/uuid)
gcloud spanner rows insert --table=Owners --database=pets-db
--instance=test-spanner-instance --data=OwnerID=$owner_uuid,OwnerName=Doug
gcloud spanner rows insert --table=Pets --database=pets-db
--instance=test-spanner-instance
--data=PetID=$pet_uuid,OwnerID=$owner_uuid,PetName='Noir',PetType='Dog',Breed='Schnoodle'
gcloud spanner databases execute-sql pets-db
--instance=test-spanner-instance
--sql='SELECT o.OwnerName, p.PetName, p.PetType, p.Breed FROM
Owners as o JOIN Pets AS p ON o.OwnerID = p.OwnerID'