SHOW COLUMNS

适用于:check marked yes Databricks SQL check marked yes Databricks Runtime

返回表中的列的列表。 如果该表不存在,则会引发异常。

语法

SHOW COLUMNS { IN | FROM } table_name [ { IN | FROM } schema_name ]

注意

关键字 INFROM 可互换。

参数

  • table_name

    标识表。 名称不得包含时态规范

  • schema_name

    使用架构名称限定 table_name 的可选替代方式。 指定此参数后,不应使用其他架构名称来限定表名称。

示例

-- Create `customer` table in the `salessc` schema;
> USE SCHEMA salessc;
> CREATE TABLE customer(
    cust_cd INT,
    name VARCHAR(100),
    cust_addr STRING);

-- List the columns of `customer` table in current schema.
> SHOW COLUMNS IN customer;
  col_name
 ---------
   cust_cd
      name
 cust_addr

-- List the columns of `customer` table in `salessc` schema.
> SHOW COLUMNS IN salessc.customer;
  col_name
 ---------
   cust_cd
      name
 cust_addr

-- List the columns of `customer` table in `salesdb` schema
> SHOW COLUMNS IN customer IN salessc;
  col_name
 ---------
   cust_cd
      name
 cust_addr