SHOW COLUMNSSHOW COLUMNS

返回表中的列的列表。Returns the list of columns in a table. 如果该表不存在,则会引发异常。If the table does not exist, an exception is thrown.

语法Syntax

SHOW COLUMNS { IN | FROM } table_identifier [ database ]

备注

关键字 INFROM 可互换。Keywords IN and FROM are interchangeable.

参数Parameters

  • table_identifiertable_identifier

    • [database_name.] table_name:表名,可选择使用数据库名称进行限定。[database_name.] table_name: A table name, optionally qualified with a database name.
    • delta.`<path-to-table>`:现有 Delta 表的位置。delta.`<path-to-table>`: The location of an existing Delta table.
  • databasedatabase

    可选的数据库名称。An optional database name. 指定表后,将从该数据库中解析该表。The table is resolved from this database when it is specified. 指定此参数后,不得使用其他数据库名称来限定表名称。When this parameter is specified then table name should not be qualified with a different database name.

    语法: { IN | FROM } database_nameSyntax: { IN | FROM } database_name

    备注

    关键字 INFROM 可互换。Keywords IN and FROM are interchangeable.

示例Examples

-- Create `customer` table in `salesdb` database;
USE salesdb;
CREATE TABLE customer(
    cust_cd INT,
    name VARCHAR(100),
    cust_addr STRING);

-- List the columns of `customer` table in current database.
SHOW COLUMNS IN customer;
+---------+
| col_name|
+---------+
|  cust_cd|
|     name|
|cust_addr|
+---------+

-- List the columns of `customer` table in `salesdb` database.
SHOW COLUMNS IN salesdb.customer;
+---------+
| col_name|
+---------+
|  cust_cd|
|     name|
|cust_addr|
+---------+

-- List the columns of `customer` table in `salesdb` database
SHOW COLUMNS IN customer IN salesdb;
+---------+
| col_name|
+---------+
|  cust_cd|
|     name|
|cust_addr|
+---------+