Description

SHOW COLUMNS is an SQL command used to view column information in a table. With this command, users can quickly obtain the column names and data types of a table.

Syntax

SHOW COLUMNS FROM [schema_name.]table_name;

Parameter Description

  • schema_name : Optional parameter, specifies the schema to which the table belongs. If omitted, the current schema is used by default.
  • table_name : Required parameter, specifies the name of the table whose column information needs to be viewed.

Examples

View column information of a table in the current schema

SHOW COLUMNS FROM household_demographics;
+-------------+------------------------+-------------------+-----------+---------+
| schema_name |       table_name       |    column_name    | data_type | comment |
+-------------+------------------------+-------------------+-----------+---------+
| tpcds_10tb  | household_demographics | hd_demo_sk        | int       |         |
| tpcds_10tb  | household_demographics | hd_income_band_sk | int       |         |
| tpcds_10tb  | household_demographics | hd_buy_potential  | string    |         |
| tpcds_10tb  | household_demographics | hd_dep_count      | int       |         |
| tpcds_10tb  | household_demographics | hd_vehicle_count  | int       |         |
+-------------+------------------------+-------------------+-----------+---------+

Frequently Asked Questions

Q1: How to view detailed information about a table (such as table structure)?

  • Use the DESCRIBE or SHOW CREATE TABLE command:
    DESCRIBE public.household_demographics;
    SHOW CREATE TABLE public.household_demographics;

Q2: Does SHOW COLUMNS support filtering conditions?

  • Direct filtering is not supported, but it can be achieved by querying INFORMATION_SCHEMA.COLUMNS:
    SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
    WHERE TABLE_NAME = 'household_demographics' AND COLUMN_NAME LIKE 'name%';