Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Van toepassing op:
Databricks SQL
Databricks Runtime
Notitie
Als u deze opdracht wilt gebruiken voor gerealiseerde weergaven of streamingtabellen, moet u Databricks Runtime versie 14.1 of hoger gebruiken.
Retourneert de instructie die is gebruikt om een opgegeven tabel of weergave te maken. De geretourneerde instructie kan een van de volgende typen zijn:
SHOW CREATE TABLE in een tijdelijke weergave of een niet-bestaande tabel wordt een uitzondering gegenereerd.
Syntaxis
SHOW CREATE TABLE { table_name | view_name }
Parameterwaarden
-
Identificeert de relatie. De naam mag geen tijdelijke specificatie of optiesspecificatie bevatten.
Voorbeelden
> CREATE TABLE test (c INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE
TBLPROPERTIES ('prop1' = 'value1', 'prop2' = 'value2');
> SHOW CREATE TABLE test;
createtab_stmt
----------------------------------------------------
CREATE TABLE `default`.`test` (`c` INT)
USING text
TBLPROPERTIES (
'transient_lastDdlTime' = '1586269021',
'prop1' = 'value1',
'prop2' = 'value2')
In het volgende voorbeeld ziet SHOW CREATE TABLE u een metrische weergave. De uitvoer legt de oorspronkelijke definitie en eventuele volgende ALTER VIEW wijzigingen vast en de weergavenaam wordt geretourneerd als een volledig gekwalificeerde driedelige naam.
> CREATE OR REPLACE VIEW sample_sales_metrics_v2
COMMENT 'Sales metrics for product and regional analysis'
TBLPROPERTIES ('created_by' = 'Evan')
WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
source: sample_sales
comment: "Sales metrics for product and regional analysis"
dimensions:
- name: product_category
expr: product_category
comment: "Category of the product sold"
- name: region
expr: region
measures:
- name: total_sales
expr: SUM(sales_amount)
comment: "Sum of all sales amounts"
- name: total_quantity
expr: SUM(quantity)
comment: "Total number of items sold"
$$;
> ALTER VIEW sample_sales_metrics_v2
SET TBLPROPERTIES ('purpose' = 'For testing');
> SHOW CREATE TABLE sample_sales_metrics_v2;
createtab_stmt
------------------------------------------------------------
CREATE VIEW main.default.sample_sales_metrics_v2 (
product_category COMMENT 'Category of the product sold',
region,
total_sales COMMENT 'Sum of all sales amounts',
total_quantity COMMENT 'Total number of items sold')
COMMENT 'Sales metrics for product and regional analysis'
TBLPROPERTIES (
'created_by' = 'Evan',
'purpose' = 'For testing')
WITH METRICS
LANGUAGE YAML
AS
$$
version: 1.1
source: sample_sales
comment: Sales metrics for product and regional analysis
dimensions:
- name: product_category
expr: product_category
comment: Category of the product sold
- name: region
expr: region
measures:
- name: total_sales
expr: SUM(sales_amount)
comment: Sum of all sales amounts
- name: total_quantity
expr: SUM(quantity)
comment: Total number of items sold
$$