- Lab
- A Cloud Guru
Setting Up for Google Cloud Spanner
Today’s global companies require a global solution for their extensive data needs. Cloud Spanner provides a highly available, SQL-compliant database solution capable of scaling horizontally on a planet-wide scale. In this hands-on lab, you’ll walk through the process of establishing a Cloud Spanner instance, creating a populated database, querying the data, and then exporting it to Google Cloud Storage
Path Info
Table of Contents
-
Challenge
Enable APIs
- From the Google Cloud console navigation, choose APIs & Libraries > Libraries.
- Enable the APIs for Cloud Spanner, Dataflow, and Cloud Storage.
-
Challenge
Create a Cloud Spanner Instance
- From the main navigation, choose Spanner in the Storage section.
- Click Create instance.
- Provide the following details:
- Name: la-spanner
- Configuration: Regional - us-central1
- Node: 1
- Click Create.
-
Challenge
Create Database and Table
- Click Create database.
- Name the database.
- Leave the dialect set to Google Standard SQL.
- In the Define your schema section enter the following code in the DDL statements box: CREATE TABLE Artists ( ArtistId INT64 NOT NULL, FirstName STRING(1024), LastName STRING(1024), BirthDate DATE ) PRIMARY KEY(ArtistId);
- Click Create.
-
Challenge
Populate Table
- Select Artists in left sidebar.
- Review the schema.
- Click Data.
- Click Insert and a query window will open.
- In the values section of the query, enter the following records between the parentheses making sure to replace the example data
- Click Format Query and wait for the query to show as valid.
- Click Run:
100, "Paul", "Cezanne", DATE("1839-01-19") 101, "Ansel", "Adams", DATE("1902-02-20") 102, "Frida", "Kahloe", DATE("1907-07-06")
-
Challenge
Edit Data
- Click on Data.
- Select the checkbox next to the Frida Kahloe record.
- Choose Edit.
- In the SET section of the query, change the LastName to Kahlo.
- Click Run.
-
Challenge
Query Data
- In the query window, click New Tab.
- In the Query field, enter: SELECT * from Artists WHERE BirthDate > '1900-01-01'*.
- Click Run.
- Review results.
-
Challenge
Create Bucket and Export Data
- Navigate to Storage.
- Click Create Bucket.
- Provide the following details:
- Name: la-spanner-export-<INSERT NUMBERS OR LETTERS HERE> (must be unique across all Cloud Storage)
- Default storage class: Regional
- Location: us-central1
- Click Create.
- Leave the public access prevention setting as the default.
- Navigate back to Spanner.
- Choose instance from left sidebar.
- Select Export.
- Select bucket to store exported data.
- Choose database to export.
- Select region.
- Click Confirm Charges checkbox.
- Click Export
- Visit Cloud Spanner to view progress of operation.
- Visit Cloud Storage bucket to confirm operation.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.