使用 Google Cloud 控制台查詢公開資料集
瞭解如何使用 Google Cloud 控制台,在 BigQuery 中找出及查詢公開資料集。
如要直接在 Google Cloud 控制台按照逐步指南操作,請按一下「Guide me」(逐步引導):
事前準備
- 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.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 選取專案。
- 按一下「授予存取權」 。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 選取專案。
- 按一下「授予存取權」 。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
-
-
Verify that billing is enabled for your Google Cloud project.
確認已啟用 BigQuery API。
如果您建立新專案,系統會自動啟用 BigQuery API。
前往 Google Cloud 控制台的「BigQuery」BigQuery頁面。
在「Explorer」窗格中,按一下
「+Add data」(+新增資料) 。在「新增資料」對話方塊的「依條件篩選」窗格中,按一下
「公開資料集」。
你可以使用「搜尋 Marketplace」欄位或篩選器縮小搜尋範圍。
選取資料集,然後按一下「View dataset」(查看資料集)。
您可以在「Explorer」窗格中,查看所選資料集的詳細資料。
(非必要) 按一下資料集旁的
「View actions」(查看動作),即可查看更多選項。每個資料集都含有資料表,點選某個資料集旁的
「Toggle node」(展開或收合節點),就能查看當中的資料表。前往 Google Cloud 控制台的「BigQuery」BigQuery頁面。
按一下
「SQL query」(SQL 查詢) 。將下列查詢複製到
查詢編輯器 :SELECT name, SUM(number) AS total FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY total DESC LIMIT 10;
如果查詢有效,您就會看見勾號和查詢處理的資料量。如果查詢無效,則會顯示驚嘆號和錯誤訊息。
按一下
「Run」(執行) 。「Query results」(查詢結果) 部分會列出最常見的姓名。資料表的標題列會包含查詢中選取的每一個資料欄名稱。
(非必要) 如要顯示查詢的持續時間和處理的資料量,請按一下
「Query results」(查詢結果) 部分的「Job information」(工作資訊) 分頁標籤。- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
- 瞭解 BigQuery 沙箱。
- 瞭解如何在Google Cloud 控制台中建立資料集及查詢資料表。
- 取得 BigQuery 的最新消息。
- 瞭解 BigQuery 定價。
- 瞭解 BigQuery 配額與限制。
如果在本教學課程中使用的 Google Cloud 專案未啟用計費功能,您需要在 BigQuery 沙箱中上傳及使用資料。BigQuery 沙箱可讓您學習 BigQuery,但可免費使用的 BigQuery 功能有限。
開啟公開資料集
根據預設,BigQuery 公開資料集會直接顯示在Google Cloud 控制台中。
在以下範例中,您可以存取公開專案 bigquery-public-data
中的資料集。
查詢公開資料集
下列步驟中,您會查詢「usa_names」公開資料集,並找到 1910 年至 2013 年之間美國最常見的姓名:
清除所用資源
如要避免系統向您的 Google Cloud 帳戶收取本頁所用資源的費用,請按照下列步驟操作。
刪除專案
如果您使用 BigQuery 沙箱查詢公開資料集,表示專案未啟用帳單功能。
如要避免付費,最簡單的方法就是刪除您為了本教學課程所建立的專案。
如要刪除專案: