Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



BigQuery Browser Tool Quickstart

This page provides a tutorial exercise in using the BigQuery browser tool to run queries, load data, and export data.

  1. Prerequisites
  2. Run a Query
  3. Create a Table
  4. Export a Table

Prerequisites

Before you can start this tutorial, you must complete the following prerequisites:

  1. Activate the BigQuery service with a Google APIs Console project

    If you are a member of an existing Google APIs Console project that already has BigQuery enabled, you can use that project, or you can create a new project. If you create a new project, you must also turn on billing for that project before you can use BigQuery with full capabilities, as described in the sign up process .

  2. Log in to the BigQuery browser and select your desired project

    The BigQuery browser provides a dropdown list of projects that you own or are a member of. Check to make sure you are using your desired project and if not, switch projects:

    1. Open the BigQuery browser tool
    2. Switch to the project that you want to use by toggling the project dropdown button on the page. Note that you must have write access in this project to complete the exercises that discuss creating tables and importing data.

    If the project name that you want to use doesn't show in the dropdown, either the BigQuery API hasn't been enabled on that project, or you haven't been added to the project. Have someone with owner rights in this project check to make sure that the BigQuery API has been activated (under the Services tab in the Google API console), and make sure you have been added to the project with write access permissions.

Run a Query

In this exercise, you will try running queries against some public data exposed by BigQuery.

Open the BigQuery browser tool . Google BigQuery has several public data tables that you can run queries against. For more information, see a full description of each sample . You can see these public tables in the browser tool by clicking the publicdata:samples tab on the left side to expand it ( publicdata is the project ID, and samples is the dataset that holds all the tables in that project).

Let's run a few basic queries against these tables. To run a query, click the Compose Query button, then enter the query SQL in the textbox at the top of the page and click Run Query . The results (or an error code) will be displayed below the query box. In the query text, tables should be qualified in the format datasetId . tableId . You can see a complete description of BigQuery's SQL syntax on the Query Reference page .

Try out the following queries in the textbox:

Create a Table

Now that you've had a chance to run queries against an existing table, let's try creating a new table and running queries against it.

The US Government records lists of baby names given to children born each year. Download the national data file from the government's Popular Baby Names page and unzip it. This zipped file consists of several comma-delimited value (CSV) files, each listing the baby names for a single year. The file names list the year described by that file.

The format of each CSV file is name , gender , count where gender is either 'M' or 'F', and count is the number of children given that name in that year.

  1. Create a new dataset to hold your table:
  2. Create your table:
    1. Select the down arrow next to your dataset and click Create new table to open the "Create Table" dialog.
    2. Select File upload .
    3. In Table ID , enter a name for your new table. Naming rules are the same as for your dataset.
    4. In Schema , enter the schema of the baby names file. A CSV schema is specified as column1_name : data_type , column2_name : data_type ,... The data in the baby names file is stored as baby_name , gender , count_of_names with data types string, string, integer. Therefore, you should enter something like this for your schema:
      name:string,gender:string,count:integer

      The values "name", "gender", and "count" are custom labels assigned to the columns in your new table.

      Note: BigQuery also supports uploading JSON files, which have a different schema structure.


    5. Select Choose file and browse to one of the yob****.txt files that you downloaded and unzipped.
    6. Click OK to upload your data.

When your table has been created and the data uploaded, the new table should appear in your dataset. Now you can run queries against it, as you did before. Here are a few queries you can try (substitute the correct dataset ID and table ID for your table):

Export a Table

You can export query results as a CSV file to your local computer, or as a permanent table to your dataset. To export query results after you run a query, click Download as CSV to download the results as a CSV file to your local computer. You can also store the results as a persistent table to any dataset in which you have write permissions by clicking Save as Table .

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.