Create Authorized Views

Check my progress

/ 20

Assign IAM permissions to both the views

Check my progress

/ 20

Grant permissions to the users to access the views

Check my progress

/ 20

Verify shared authorized views in customer projects

Check my progress

/ 40

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

GSP1041

Google Cloud 自學實驗室

總覽

在常見的應用情境中,Google Cloud 資料共用合作夥伴擁有專屬資料集,客戶則根據分析用途取用這些資料集。客戶必須訂閱這類資料、在自己的平台上查詢、利用自有資料集擴增內容,再透過圖表工具製作供自家顧客使用的資訊主頁。透過這種模式,資料共用合作夥伴可簡化並加快打造資料導向解決方案,進而創造價值。

總覽示意圖

整合 BigQuery 與 Google Cloud IAM 後,您就能設定 BigQuery 物件的權限,讓組織內外的使用者都能存取。在本實驗室中,您將瞭解如何使用 BigQuery 的授權 view,分享由資料共用合作夥伴提供的客戶專屬資料。本實驗室提供三個專案:擁有資料集的資料共用合作夥伴專案,以及兩個獨立的客戶專案,這兩位客戶將從各自專案存取資料集子集。各個客戶專案將只會列出與所屬州相關的顧客資訊。

目標

本實驗室的學習內容如下:

  • 將資料集從資料共用合作夥伴專案複製到客戶的 BigQuery 專案
  • 限制特定客戶取用資料共用合作夥伴專案的資料集
  • 合併資料共用合作夥伴提供的資料集與客戶的資料集,以強化商業智慧

設定和需求

瞭解以下事項後,再點選「Start Lab」按鈕

請詳閱以下操作說明。實驗室活動會計時,且中途無法暫停。點選「Start Lab」後就會開始計時,顯示可使用 Google Cloud 資源的時間。

您將在真正的雲端環境完成實作實驗室活動,而不是模擬或示範環境。為此,我們會提供新的暫時憑證,供您在實驗室活動期間登入及存取 Google Cloud。

為了順利完成這個實驗室,請先確認:

  • 可以使用標準的網際網路瀏覽器 (Chrome 瀏覽器為佳)。
注意事項:請使用無痕模式 (建議選項) 或私密瀏覽視窗執行此實驗室,這可以防止個人帳戶和學員帳戶之間的衝突,避免個人帳戶產生額外費用。
  • 是時候完成實驗室活動了!別忘了,活動一旦開始將無法暫停。
注意事項:務必使用實驗室專用的學員帳戶。如果使用其他 Google Cloud 帳戶,可能會產生額外費用。

如何開始實驗室及登入 Google Cloud 控制台

  1. 按一下「Start Lab」按鈕。如果實驗室會產生費用,請在開啟的對話方塊中選取付款方式。右側的「Lab setup and access」面板會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 此實驗室所需的臨時憑證 (使用者名稱和密碼)
    • 完成此實驗室所需的其他資訊 (如有)

    請注意,實驗室計時器位於頁面頂端附近,會顯示剩餘時間。

  2. 按一下「Open Google Cloud console」。如果使用 Chrome 瀏覽器,也可以按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」。

    接著,實驗室會啟動相關資源,並開啟另一個分頁,顯示「登入」頁面。

    提示:您可以在不同的視窗並排開啟分頁。

    注意:頁面顯示「選擇帳戶」對話方塊時,請點選「使用其他帳戶」。
  3. 如有必要,請將下方的 Username 貼到「登入」對話方塊。

    {{{user_0.username | "Username"}}}

    您也可以在「Lab setup and access」面板找到「Username」。

  4. 點選「下一步」。

  5. 複製下方的 Password,並貼到「歡迎使用」對話方塊。

    {{{user_0.password | "Password"}}}

    您也可以在「Lab setup and access」面板找到「Password」。

  6. 點選「下一步」。

    重要事項:請務必使用實驗室提供的憑證,而非自己的 Google Cloud 帳戶憑證。 注意:如果使用自己的 Google Cloud 帳戶來進行這個實驗室,可能會產生額外費用。
  7. 繼續點按後續頁面:

    • 接受條款及細則。
    • 由於這是臨時帳戶,請勿新增救援選項或雙重驗證機制。
    • 請勿申請免費試用。

Google Cloud 控制台稍後會在這個分頁開啟。

注意:如要使用 Google Cloud 產品和服務,請按一下「導覽選單」,或在「搜尋」欄位輸入服務或產品名稱。「導覽選單」圖示和搜尋欄位

工作 1:建立授權 view

在第一個專案中,您將扮演資料共用合作夥伴,使用授權 view 建立及共用資料集。

建立授權 view A

  1. 開啟實驗室窗格的「Data Sharing Partner Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」。

  3. 執行下列查詢,根據公開地理位置資料集為客戶 A 建立授權 view。

SELECT * FROM `bigquery-public-data.geo_us_boundaries.zip_codes` WHERE state_code="TX" LIMIT 4000
  1. 在工具列依序點選「儲存」>「儲存 view」。

  2. 不更動專案的預設設定,並在「資料集」部分選取 demo_dataset。

  3. 在「資料表」部分,輸入 authorized_view_a。

  4. 按一下「儲存」。

建立授權 view B

  1. 在查詢編輯器中,移除剛才執行的查詢。

  2. 執行下列查詢,根據公開地理位置資料集為客戶 B 建立授權 view。

SELECT * FROM `bigquery-public-data.geo_us_boundaries.zip_codes` WHERE state_code="CA" LIMIT 4000
  1. 在工具列依序點選「儲存」>「將 view 另存為」。

  2. 不更動專案的預設設定,並在「資料集」部分選取 demo_dataset。

  3. 在「資料表」部分,輸入 authorized_view_b。

  4. 按一下「儲存」。

授權 view 應如下所示:

授權 view

點選「Check my progress」,確認目標已達成。 建立授權 view

工作 2:為兩個 view 指派 IAM 權限

  1. 在「傳統版 Explorer」窗格開啟 demo_dataset,依序點選「+ 共用」 >「授權 view」。

授權 view

  1. 新增需要授權才能共用的授權 view A:.demo_dataset.authorized_view_a。

  2. 點選「新增授權」。

  3. 新增需要授權才能共用的授權 view B:.demo_dataset.authorized_view_b。

  4. 點選「新增授權」。授權 view 應如下所示:

授權 view

  1. 按一下「關閉」。

點選「Check my progress」,確認目標已達成。 為兩個 view 指派 IAM 權限

工作 3:將 view 的存取權限授予使用者

在本節中,您將指派權限給每位客戶使用者與相關的授權 view。

為客戶 A 指派 IAM 權限

  1. 在專案的 demo_dataset,開啟 authorized_view_a view。

  2. 依序點選「共用」>「管理權限」。

  3. 按一下「新增主體」,然後新增「客戶 A」使用者:

  4. 選取「BigQuery 資料檢視者」角色。

新增 BigQuery 資料檢視者主體

  1. 按一下「儲存」。

為客戶 B 指派 IAM 權限

  1. 在專案的 demo_dataset,開啟 authorized_view_b view。

  2. 依序點選「共用」>「管理權限」。

  3. 按一下「新增主體」,然後新增「客戶 B」使用者:

  4. 選取「BigQuery 資料檢視者」角色。

新增 BigQuery 資料檢視者主體

  1. 按一下「儲存」。

點選「Check my progress」,確認目標已達成。 將 view 的存取權限授予使用者

工作 4:驗證客戶專案中的共用授權 view

在本節中,您將驗證授權 view 已正確分享給每位客戶使用者。

驗證客戶 A 的授權 view 共用設定

  1. 關閉「Data Sharing Partner Project Console」,然後開啟實驗室窗格中的「Customer A Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」。

  3. 執行下列查詢,以選取資料共用合作夥伴專案中 demo_dataset.authorized_view_a view 的所有資料欄:

SELECT * FROM `{{{isv_project.project_id|Project ID}}}.demo_dataset.authorized_view_a`

現在應會看到結果已填入。

  1. 在查詢工具列,依序選取「儲存」>「儲存 view」。

  2. 按一下「資料集」欄位,然後選取 customer_a_dataset。

  3. 在「資料表」欄位,輸入 customer_a_table。

  4. 按一下「儲存」。現在您應可看見資料集和資料表,也能進行查詢。

現在您要將「客戶 A」授權 view 中的資料,彙整至客戶專屬資料集,生成新的洞察資料。

  1. 執行下列查詢,找出特定州內的所有顧客。由於客戶 A 可存取的授權 view 已按德州篩選資料,因此查詢結果應只會傳回該州的顧客。
SELECT geos.zip_code, geos.city, cust.last_name, cust.first_name FROM `{{{consumer_project.project_id|Customer A Project ID}}}.customer_a_dataset.customer_info` as cust JOIN `{{{isv_project.project_id|Data sharing partner Project ID}}}.demo_dataset.authorized_view_a` as geos ON geos.zip_code = cust.postal_code;

查詢結果應如下所示:

客戶 A 查詢結果

  1. 執行下列查詢,確認只有看見客戶 A 的專屬資料。
SELECT * FROM `{{{isv_project.project_id|Project ID}}}.demo_dataset.authorized_view_b`

您應該會收到下列錯誤訊息:

Access Denied: Table qwiklabs-gcp-04-b39db6c444b1:demo_dataset.authorized_view_b: User does not have permission to query table qwiklabs-gcp-04-b39db6c444b1:demo_dataset.authorized_view_b.

驗證客戶 B 的授權 view 共用設定

  1. 關閉「Customer Project A Console」,然後開啟實驗室窗格中的「Customer B Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」。

  3. 執行下列查詢,以選取資料共用合作夥伴專案中 demo_dataset.authorized_view_b view 的所有資料欄:

SELECT * FROM `{{{isv_project.project_id|Project ID}}}.demo_dataset.authorized_view_b`

現在應會看到結果已填入。

  1. 在查詢工具列,依序選取「儲存」>「儲存 view」。

  2. 按一下「資料集」欄位,然後選取 customer_b_dataset。

  3. 在「資料表」欄位,輸入 customer_b_table。

  4. 按一下「儲存」。現在您應可看見資料集和資料表,也能進行查詢。

現在您要將「客戶 B」授權 view 中的資料,彙整至客戶專屬資料集,生成新的洞察資料。

  1. 執行下列查詢,找出特定州內的所有顧客。由於客戶 A 可存取的授權 view 已按加州篩選資料,因此查詢結果應只會傳回該州的顧客。
SELECT geos.zip_code, geos.city, cust.last_name, cust.first_name FROM `{{{consumer_project_2.project_id|Customer A Project ID}}}.customer_b_dataset.customer_info` as cust JOIN `{{{isv_project.project_id|Data Sharing Partner Project ID}}}.demo_dataset.authorized_view_b` as geos ON geos.zip_code = cust.postal_code;

查詢結果應如下所示:

客戶 B 查詢結果

  1. 執行下列查詢,確認只有看見客戶 B 的專屬資料。
SELECT * FROM `{{{isv_project.project_id|Project ID}}}.demo_dataset.authorized_view_a`

您應該會收到下列錯誤訊息:

Access Denied: Table qwiklabs-gcp-04-b39db6c444b1:demo_dataset.authorized_view_a: User does not have permission to query table qwiklabs-gcp-04-b39db6c444b1:demo_dataset.authorized_view_a.

點選「Check my progress」,確認目標已達成。 驗證客戶專案中的共用授權 view

恭喜!

在本實驗室中,您學會將資料共用合作夥伴提供的資料集複製到客戶的 BigQuery 專案、限制特定客戶使用資料共用合作夥伴專案的資料集,以及將該資料集與客戶的資料集合併,藉此強化商業智慧。

Google Cloud 教育訓練與認證

協助您瞭解如何充分運用 Google Cloud 的技術。我們的課程會介紹專業技能和最佳做法,讓您可以快速掌握要領並持續進修。我們提供從基本到進階等級的訓練課程,並有隨選、線上和虛擬課程等選項,方便您抽空參加。認證可協助您驗證及證明自己在 Google Cloud 技術方面的技能和專業知識。

使用手冊上次更新日期:2026 年 7 月 20 日

實驗室上次測試日期:2026 年 7 月 20 日

Copyright 2026 Google LLC 保留所有權利。Google 和 Google 標誌是 Google LLC 的商標,其他公司和產品名稱則有可能是其關聯公司的商標。

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We can notify you via email when it becomes available

Great!

We can contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.