DESCRIBE
is a shortcut for SHOW COLUMNS.
TIP
DESCRIBE
also lists the indexes on a table or materialized view, whereas SHOW COLUMNS
doesn’t.
Syntax
Parameters
Parameter or clause | Description |
---|
relation_name | The table, source, sink, view or materialized view whose columns will be listed. |
Examples
CREATE TABLE customers (
customer_id BIGINT PRIMARY KEY,
name VARCHAR,
email VARCHAR
);
COMMENT ON COLUMN customers.customer_id IS 'Unique identifier for each customer';
COMMENT ON COLUMN customers.name IS 'Name of the customer';
COMMENT ON COLUMN customers.email IS 'Email address of the customer';
COMMENT ON TABLE customers IS 'All customer records';
CREATE INDEX idx_customers_email ON customers(email);
After creating the table, columns, and indexes, as well as adding comments to each of them, we can use the DESCRIBE
command to see all the information in a structured format.
| Name | Type | Is Hidden | Description |
| ------------------- | --------------------------------------------------------------------- | --------- | ----------------------------------- |
| customer_id | bigint | false | Unique identifier for each customer |
| name | character varying | false | Name of the customer |
| email | character varying | false | Email address of the customer |
| primary key | customer_id | | |
| distribution key | customer_id | | |
| idx_customers_email | index(email ASC, customer_id ASC) include(name) distributed by(email) | | |
| table description | customers | | All customer records |