SHOW TABLES DROPPED
適用於: Databricks SQL
Databricks Runtime 12.2 LTS 和更新版本
重要
這項功能處於公開預覽狀態。
此命令會列出已在 Unity Catalog中掉落於 schema 內的所有 tables,但仍可復原。 具體來說,它會列出在保留期間內所有被刪除的 tables(預設為 7 天)。 如果 schema 或 catalog 已丟失,系統將會報告錯誤。 如果未指定 schema,則會從目前的 schema傳回 tables。
這個指令只會 listtables 申請者可以 UNDROP。
因此,中繼存放區/catalog/schema 的擁有者有權在各自的安全擁有範圍內 list 所有已被卸除的 tables。
具有 table 層級擁有權的使用者,只要在父 catalog 擁有 USE CATALOG
許可權,並且在父 schema擁有 USE SCHEMA
許可權,將只能檢視他們在輸入 catalog/schema 中擁有的 tables。
語法
SHOW TABLES DROPPED [ { FROM | IN } schema_name ] [ LIMIT maxResults ]
Parameters
-
指定從 schema 中列出的 tables 名稱。 如果未提供,請使用目前的 schema。 如果 schema 或 catalog 不存在或已刪除,就會引發 SCHEMA_NOT_FOUND 錯誤。
maxResult
整數常值,限制傳回 tables 的數目。
傳回
命令 s 產生的報表包括 tables 的 list,並具有以下 columns:
名稱 | 資料類型 | Nullable | 描述」 |
---|---|---|---|
catalogName | 字串 | 否 | 所列出 table的名稱為 catalog。 |
schemaName | 字串 | 否 | 列表中 table的 schema 名稱。 |
tableName | 字串 | 否 | 已移除的 table 名稱 |
tableId | 字串 | 否 | 可用來識別和取消卸除特定版本 table的 table 標識碼。 |
tableType | 字串 | 否 | Unity Catalog 中已卸除之 table 的類型 |
deletedAt | 字串 | 否 | 卸除 table 的時間。 |
createdAt | 字串 | 否 | 建立 table 的時間。 |
updatedAt | 字串 | 否 | 上次更新 table 的時間。 |
createdBy | 字串 | 否 | 創建 table的校長。 |
擁有者 | 字串 | 否 | 擁有 table的擁有者。 |
comment | 字串 | 是 | 這是可選的 table 批註。 |
範例
— List dropped tables from an existing schema + catalog.
> USE CATALOG default;
> USE SCHEMA my_schema;
> CREATE TABLE my_table_1;
> CREATE TABLE my_table_2;
> DROP TABLE my_table_1;
> SHOW TABLES DROPPED;
catalogname schemaname tablename tableid tabletype deletedat createdat updatedat createdby owner comment
----------- ---------- ---------- ------- --------- ----------------------------- ----------------------------- ----------------------------- ------------- ------------- -------
default my_schema my_table_1 <uuid> managed 2023-05-03 AD at 18:17:56 UTC 2023-05-03 AD at 18:17:00 UTC 2023-05-03 AD at 18:17:00 UTC alf@melmak.et alf@melmak.et
-- Create a new table with name `my_table_1` since other was dropped.
> CREATE TABLE my_table_1;
> DROP TABLE my_table_1;
> SHOW TABLES DROPPED IN default.my_schema;
catalogname schemaname tablename tableid tabletype deletedat createdat updatedat createdby owner comment
----------- ---------- ---------- ------- --------- ----------------------------- ----------------------------- ----------------------------- ------------- ------------- -------
default my_schema my_table_1 <uuid> managed 2023-05-03 AD at 18:17:56 UTC 2023-05-03 AD at 18:17:00 UTC 2023-05-03 AD at 18:17:00 UTC alf@melmak.et alf@melmak.et
— List dropped tables when some are past the retention period.
> USE CATALOG default;
> USE SCHEMA my_schema;
> CREATE TABLE my_table_1;
> DROP TABLE my_table_1;
-- Wait 8 days (1 more than 7 day retention period)
> SHOW TABLES DROPPED;
catalogname schemaname tablename tableid tabletype deletedat createdat updatedat createdby owner comment
----------- ---------- ---------- ------- --------- ----------------------------- ----------------------------- ----------------------------- ------------- ------------ -------