SHOW CREATE TABLE

Şunlar için geçerlidir:onay işareti evet olarak işaretlenmiş Databricks SQL onay işareti evet olarak işaretlenmiş Databricks Runtime

Not

Bu komutu gerçekleştirilmiş görünümlerde veya akış tablolarında kullanmak için Databricks Runtime sürüm 14.1 veya üzerini kullanmanız gerekir.

Verilen bir tablo veya görünüm oluşturmak için kullanılan ifadeyi getirir. Döndürülen ifade aşağıdaki türlerden herhangi biri olabilir:

SHOW CREATE TABLE geçici bir görünümde veya mevcut olmayan bir tabloda özel durum oluşturur.

Sözdizimi

SHOW CREATE TABLE { table_name | view_name }

Parametreler

Örnekler

> 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')

Aşağıdaki örnekte ölçüm görünümü gösterilmektedir SHOW CREATE TABLE . Çıkış özgün tanımı ve sonraki ALTER VIEW değişiklikleri yakalar ve görünüm adı tam üç parçalı bir ad olarak döndürülür.

> 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
 $$