
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
In this lab, you create Spanner instances and databases using the Google Cloud Console.
In this lab, you learn how to:
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 will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Click Authorize.
Your output should now look like this:
Output:
Output:
Example output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
On the Google Cloud Console title bar, click the Navigation Menu (). Scroll to the Database section and click Spanner.
Click the Create a Provisioned Instance button and name your instance my-first-instance. Select the region
Wait for the instance to be created, then you should be redirected to the Instance Overview page. Click the Create Database button, you may need to scroll to the bottom to find it. Name your database my-database, choose Google Standard SQL, then scroll down and click the Create button.
Click Spanner Studio in the left menu listing.
Click the blue + icon on the top ribbon.
Enter the following CREATE TABLE statement, and then click the Run button.
Wait for the operation to complete. Your table should appear in the list of tables for that database. Expand the Tables section of the Explorer menu on the left to see the table name.
Click Clear Query and run the following INSERT query to add a row the your new table. Assuming you have no syntax errors, it should tell you 1 row was inserted. In the query, you are simply inserting a record.
Repeat the previous steps to add a few more records. Don't forget to change the TableID
field each time so it is unique. You can enter any values you like for Field1
. Add 2 or 3 more records.
Click Clear Query and run the following SELECT query.
In the top-left corner of the Spanner workspace area, click the All instances link.
Click the Create Instance button and name your instance my-second-instance.
In the Choose a configuration section, click the Compare Region Configurations button.
us-central1 (Iowa)
. In the second dropdown, select Multi-region configuration nam3 (Northern Virginia/South Carolina/Iowa)
. nam-eur-asia1 (Iowa/Oklahoma/Belgium/Taiwan/South Carolina)
and compare the replicas and the costs between the two multi-region configuration. Close the Compare region configurations pane. Return to the configuration screen and set the configuration to Regional and
In the Allocate compute capacity section, change the Unit dropdown to Nodes.
In the Summary section, note the costs and maximum storage capacity. Increase the number of nodes to see the changes to costs and capacity.
In the Allocate compute capacity section, change the Unit dropdown to Processing Units. Processing units are added in increments of 100. Set the value to 100 (this is the smallest Spanner instance possible).
Note the costs and capacity. Click Create to create the instance.
As you did earlier, create a database called pets-db in the second instance.
Add the tables Owners and Pets to the database using the following DDL code in the Spanner Studio.
Note: The primary keys for this database are not integers, but 36 character strings. These keys are meant to be universally unique identifiers (UUIDs). You could enter any unique strings less than or equal to 36 characters and it would work. If you want to generate proper UUIDs though, you can make the following request in a browser and at the top of the page, a UUID will be shown.
Create a second database in your Spanner instance named my-second-instance. Name the database pets-postgres. This time, choose PostgreSQL when prompted to select a database dialect. As a reminder, make sure you are at the Instance Overview page. Click the Create Database button.
The DDL code for the Pets database using PostgreSQL syntax is as follows. Create these tables in the same manner as earlier steps using the Spanner Studio.
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2024 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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one