You can use the Google Cloud Console as a visual interface to complete tasks like running queries, loading data, and exporting data. This quickstart shows you how to query tables in a public dataset and how to load sample data into BigQuery using the Cloud Console.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.
- BigQuery is automatically enabled in new projects. To activate BigQuery in a preexisting project, go to Enable the BigQuery API.
- BigQuery provides a sandbox if you do not want to provide a credit card or enable billing for your project. The steps in this topic work for a project whether or not your project has billing enabled. If you optionally want to enable billing, see Learn how to enable billing.
Query a public dataset
The Cloud Console provides an interface to query tables, including public datasets offered by BigQuery.
In this example, you query the USA Name Data public dataset to determine the most common names in the US between 1910 and 2013.
BigQuery public datasets are displayed by default in the Cloud Console. To open the public datasets project manually, enter the following URL in your browser.
https://console.cloud.google.com/bigquery?p=bigquery-public-data&page=project
To query data in a public dataset, follow these steps:
Go to the BigQuery page in the Cloud Console.
If the Editor tab isn't visible, then click Compose new query
.Copy and paste the following query into the Editor field.
SELECT name, gender, SUM(number) AS total FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name, gender ORDER BY total DESC LIMIT 10
If the query is valid, then a check mark appears along with the amount of data that the query will process. This metric helps you determine the cost of running the query. If the query is invalid, then an exclamation point appears along with an error message.
Click Run. The query results page appears below the query window. At the top of the query results page, the time elapsed and the data processed by the query are displayed. Below the
Query complete...
message, a table displays the query results with a header row containing the name of each column you selected in the query.
Load data into a table
Next, load data into a table and query it.
Download the data
The file you're downloading contains approximately 7 MB of data about popular baby names, and it is provided by the US Social Security Administration.
Download the baby names zip file.
Extract the file onto your machine.
The zip file contains a
NationalReadMe.pdf
file that describes the dataset. Learn more about the dataset.Open the file named
yob2014.txt
to see what the data looks like. The file is a comma-separated value (CSV) file with the following three columns: name, sex (M
orF
), and number of children with that name. The file has no header row.Note the location of the
yob2014.txt
file so that you can find it later.
Create a dataset
Next, create a dataset in the Cloud Console to store the data.
If necessary, open the BigQuery page in the Cloud Console.
In the Explorer panel, click your project name.
In the details panel, click Create dataset
.On the Create dataset page, do the following:
- For Dataset ID, enter
babynames
. For Data location, choose United States (US). Currently, the public datasets are stored in the
US
multi-region location. For simplicity, place your dataset in the same location.
- For Dataset ID, enter
Leave all of the other default settings in place and click Create dataset.
Load the data into a new table
Next, load the data into a new table.
In the Explorer panel, click the babynames dataset that you created.
In the details panel, click Create table
.Use the default values for all settings unless otherwise indicated.
On the Create table page, do the following:
- In the Source section, for Create table from, choose Upload.
- For Select file, click Browse, navigate to the
yob2014.txt
file, and click Open. - For File format, choose CSV.
- In the Destination section, for Table name, enter
names_2014
. In the Schema section, click the Edit as text toggle and paste the following schema definition into the box.
name:string,gender:string,count:integer
Click Create table.
Wait for BigQuery to create the table and load the data. When BigQuery finishes loading the data, a check mark appears in the Job history panel.
Preview the table
To preview the first few rows of the data, follow these steps:
In the Explorer panel, expand babynames and select names_2014.
In the details panel, click Preview. BigQuery displays the first few rows of the table.
Query the table
Now that you've loaded data into a table, you can query it. The process is identical to the previous example, except that this time, you're querying your table instead of a public table.
Click Compose new query
. A new query editor tab opens.Copy and paste the following query into the query text area. This query retrieves the top five baby names for US males in 2014.
SELECT name, count FROM `babynames.names_2014` WHERE gender = 'M' ORDER BY count DESC LIMIT 5
Click Run. The results are displayed below the query window.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.
If necessary, open the BigQuery page in the Cloud Console.
In the Explorer panel, click the babynames dataset that you created.
In the details panel, click Delete dataset. This action deletes the dataset, the table, and all the data.
In the Delete dataset dialog, confirm the delete command by typing the name of your dataset (
babynames
) and click Delete.
What's next
To learn more about using the Cloud Console, see Using the Cloud Console.
To learn how to load a JSON file with nested and repeated data, see Loading nested and repeated JSON data.
To learn more about loading data into BigQuery, see Introduction to loading data.
To learn more about querying data, see Overview of querying BigQuery data.
To learn more about accessing BigQuery programmatically, see the REST API reference or the BigQuery client libraries page.