如何显示数据块中的所有视图

时间:2019-03-05 06:00:06

标签: azure databricks azure-databricks

我用过

CREATE [OR REPLACE] [[GLOBAL] TEMPORARY] VIEW

创建一些视图。我想显示所有视图。

下面的命令不起作用。

  show views

但是当我使用

 show tables

结果包括视图。 我很困惑

2 个答案:

答案 0 :(得分:0)

article有助于了解如何在Azure Databricks中使用“视图”。

示例:

-- Create a persistent view view_deptDetails in database1. The view definition is recorded in the underlying metastore
CREATE VIEW database1.view_deptDetails
    AS SELECT * FROM company JOIN dept ON company.dept_id = dept.id;

-- Create or replace a local temporary view from a persistent view with an extra filter
CREATE OR REPLACE TEMPORARY VIEW temp_DeptSFO
    AS SELECT * FROM database1.view_deptDetails WHERE loc = 'SFO';

-- Access the base tables through the temporary view
SELECT * FROM temp_DeptSFO;

-- Create a global temp view to share the data through different sessions
CREATE GLOBAL TEMP VIEW global_DeptSJC
    AS SELECT * FROM database1.view_deptDetails WHERE loc = 'SJC';

-- Access the global temp views
SELECT * FROM global_temp.global_DeptSJC;

-- Drop the global temp view, temp view, and persistent view.
DROP VIEW global_temp.global_DeptSJC;
DROP VIEW temp_DeptSFO;
DROP VIEW database1.view_deptDetails;

article有助于了解如何在Azure Databricks中使用“显示表​​”。

示例:

SHOW TABLES [{FROM|IN} db_name] [LIKE 'pattern']

希望这会有所帮助。

答案 1 :(得分:0)

  • SHOW VIEWS;
  • SHOW VIEWS FROM DATABASE;
  • SHOW VIEWS IN DATABASE;

这些所有查询都适用于 Databricks-DeltaLake 集群,不适用于 Databaricks 集群。