Create an instance and database

Check my progress

/ 5

Create a schema for the database

Check my progress

/ 5

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

GSP102

Google Cloud self-paced labs

Overview

Cloud Spanner is a fully managed, mission-critical, relational database service. It offers transactional consistency at global scale, schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication for high availability.

Cloud Spanner offers the following features:

  • Strong consistency, including strongly consistent secondary indexes.
  • SQL support, with ALTER statements for schema changes.
  • Managed instances with high availability through transparent, synchronous, built-in data replication.

Cloud Spanner offers regional and multi-region instance configurations.

Cloud Spanner is ideal for relational, structured, and semi-structured data that requires high availability, strong consistency, and transactional reads and writes.

Other storage options

Consider an alternative to Cloud Spanner in the following common scenarios:

What you'll learn

In this lab, you learn how to perform the following tasks:

  • Create a Cloud Spanner instance and database.
  • Create a database schema using Data Definition Language (DDL).
  • Insert, edit, and delete data in a table.
  • Run a SQL query using Spanner Studio.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:

    • The Open Google Cloud console button
    • The temporary credentials (username and password) that you must use for this lab
    • Other information, if needed, to step through this lab

    Note that the lab timer is located near the top of the page, showing the remaining time.

  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab setup and access panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab setup and access panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Task 1. Create an instance

When you first use Cloud Spanner, you must create an instance, which is an allocation of resources that Cloud Spanner databases use in that instance.

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click View all products, and then under Databases, click Spanner.

  2. Click Create a provisioned instance.

  3. Select Enterprise, and then click Continue.

  4. For Instance name, enter Test Instance

  5. Leave Instance ID as its default value, and then click Continue.

  6. On the Choose a configuration page, select Regional.

  7. For Select a configuration, select the region.

    Do not select a different region for the instance. The region is the only region that this lab environment supports for instance creation.

  8. Click Continue.

  9. Leave the Configure compute capacity settings as their defaults, and then click Create.

Your instance now appears on the Instance details page.

Note: If you receive an error similar to region violates constraint constraints/gcp.resourceLocations on the resource projects/qwiklabs-gcp-XX-XXXXXXXXX, return to the Choose a configuration section. Verify that you selected the specified lab region in step 7, and then proceed to create the instance.

Task 2. Create a database

  1. On the Instance overview page, click Create database.

  2. For Database name, enter example-db, and then click Create.

The Database overview page opens for the new database you created.

Click Check my progress to verify the objective.

Create an instance and database

Task 3. Create a schema

The Google Cloud console provides two ways to create, alter, and delete tables and indexes in a database:

  • Use the default database editor to specify each part of tables, columns, and indexes.
  • Enter SQL statements in Cloud Spanner Data Definition Language (DDL) syntax.

This lab uses DDL.

  1. Click Create table.

  2. In the Untitled query field, replace the existing query with the following DDL statement:

CREATE TABLE Singers ( SingerId INT64 NOT NULL, FirstName STRING(1024), LastName STRING(1024), SingerInfo BYTES(MAX), BirthDate DATE, ) PRIMARY KEY(SingerId);
  1. Click Run.

Click Check my progress to verify the objective.

Create a schema for your database

Task 4. Insert and modify data

The Google Cloud console provides an interface for inserting, editing, and deleting data.

Insert data

  1. On the Database overview page, click Singers.

  2. In the navigation pane, click Data, and then click Insert.

  3. Replace the placeholder values for the following fields:

Field Value
SingerID: INT64 1
FirstName: STRING 'Marc'
LastName: STRING 'Richards'
SingerInfo: BYTES NULL
BirthDate: DATE NULL

Your query should look similar to the following:

Query editor showing the INSERT statement with updated field values

Note: Make sure to replace SingerID with the given value in the Where condition comment.
  1. Click Run.

  2. On the Database overview page, click Singers > Data to verify that the Singers table now has one row.

  3. Click Insert to add an additional row, and replace the placeholder values with the following:

Field Value
SingerID: INT64 2
FirstName: STRING 'Catalina'
LastName: STRING 'Smith'
SingerInfo: BYTES NULL
BirthDate: DATE NULL
  1. Click Run.

  2. On the Database overview page, click Singers > Data to verify that the Singers table now has two rows.

You can also insert empty string values when you enter data.

  1. Click Insert.

  2. Replace the placeholder values with the following:

Field Value
SingerID: INT64 3
FirstName: STRING 'Kena'
LastName: STRING ' '
SingerInfo: BYTES NULL
BirthDate: DATE NULL
  1. Click Run.

  2. On the Database overview page, click Singers > Data to verify that the Singers table now has three rows, and that the row for SingerId 3 has an empty string for LastName.

Edit data

In this section, you continue working with the Singers table.

  1. Select the checkbox next to the row for SingerId 3.

  2. Click Edit.

  3. Update the placeholder values with the following:

Field Value
BirthDate: DATE '1961-04-01'
SingerInfo: BYTES NULL
[all other fields] [leave as-is]

Your query should look similar to the following:

The lines of code in the query displaying the previously entered values for birth date and singer info

  1. Click Run.

  2. On the Database overview page, click Singers > Data.

The row for SingerId 3 in the Singers table now has a BirthDate value.

Delete data

Now delete a row of data from the table.

  1. Select the checkbox next to the row for SingerId 2.

  2. Click Delete.

You can safely ignore the warning that appears in the dialog.

  1. In the confirmation dialog, click Confirm.

The Singers table now has two rows.

Run a query

You can execute a SQL statement on the query page of your database.

  1. Navigate to your Spanner database by clicking Google Standard SQL Database in the navigation breadcrumb path:

Database highlighted in the navigation path

  1. In the navigation pane, click Spanner Studio.

  2. Click Clear to clear the query you used for your table.

  3. In the query editor, enter the following query:

SELECT * FROM Singers
  1. Click Run.

The Google Cloud console displays the result of your query.

Task 5. Test your knowledge

Test your knowledge about Cloud Spanner by answering the following question.

Congratulations!

You've successfully created a Cloud Spanner database and executed a SQL statement using the query editor!

Next steps / Learn more

This lab is part of a series of labs called Qwik Starts. These labs are designed to give you a brief introduction to the many features available with Google Cloud. Review the list of "Qwik Starts" in the Google Cloud Skills Boost catalog to find the next lab you want to take!

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated November 11, 2026

Lab Last Tested September 24, 2025

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We can notify you via email when it becomes available

Great!

We can contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.