共用方式為


外部數據表

適用於:核取記號為「是」Databricks SQL 核取記號為「是」Databricks Runtime

Unity Catalog 和內建的 Azure Databricks Hive 中繼存放區會使用管理資料表的預設位置。 Unity Catalog 引進數個新的安全物件,以將許可權授予雲端物件儲存中的數據。

外部數據表

外部資料表是利用 LOCATION 子句來參考外部儲存路徑的 資料表

記憶體路徑應該包含在您已獲授與存取權的現有 外部位置 中。

或者,您也可以參考 您已獲授與存取權的儲存認證

使用外部表可以讓已獲授權存取外部表的使用者不需顧慮儲存路徑、外部位置和儲存憑證。

警告

如果資料庫架構已在您的工作區層級 Hive 中繼存放區中註冊,則使用 CASCADE 選項卸除該資料庫架構將導致該位置中的所有檔案被遞歸地刪除,而不論數據表類型(Managed 或 External)。

如果架構註冊至 Unity 目錄中繼存放區,則會以遞歸方式刪除 Unity Catalog Managed 數據表的檔案。 不過,不會刪除 外部數據表 的檔案。 您必須直接使用雲端儲存體提供者來管理這些檔案。

因此,為了避免意外遺失資料,您絕對不應該將架構註冊到已有資料的 Hive 中繼存放區。 您也不應該在 Hive 中繼存放區架構或包含 Unity 目錄受控數據表的位置中建立新的外部數據表。

關聯性的圖形表示法

下圖描述兩者之間的關聯性:

  • 記憶體認證
  • 外部地點
  • 外部數據表
  • 記憶體路徑
  • IAM 實體
  • Azure 服務帳戶

外部位置 ER 圖表

範例

-- `finance` can create an external table over specific object within the `finance_loc` location
> CREATE TABLE sec_filings LOCATION 'abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings';

-- Create or replace an external table from a query
> CREATE OR REPLACE TABLE sec_filings
  LOCATION 'abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings'
  AS (SELECT * FROM current_filings);

-- Cannot list files under an external table without permissions on it
> LIST `abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings`
  Error
> LIST `abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings/_delta_log`
  Error

-- Grant access to sec_filings to all employees
> GRANT SELECT ON TABLE sec_filings TO employee;

-- Any member of the `employee` group can securely read sec_filings
> SELECT count(1) FROM sec_filings;
 20

-- Any member of the `employee` group can list files under the sec_filings table
> LIST `abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings`
  _delta_log
> LIST `abfss://container@storageaccount.dfs.core.windows.net/depts/finance/sec_filings/_delta_log`
  00000.json