Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

PG_GET_COLS

Returns the column metadata for a table or view definition.

Syntax

Copy
pg_get_cols('name')

Arguments

name

The name of an Amazon Redshift table or view.

Return Type

VARCHAR

Usage Notes

The PG_GET_COLS function returns one row for each column in the table or view definition. The row contains a comma-separated list with the schema name, relation name, column name, data type, and column number.

Example

The following example returns the column metadata for a view named SALES_VW.

Copy
select pg_get_cols('sales_vw'); pg_get_cols -------------------------------------------- (public,lbv,c0,integer,0) (public,lbv,c1,boolean,1) (public,lbv,c2,"character(45)",2) (public,lbv,c3,"character varying(256)",3) (4 rows)

The following example returns the column metadata for the SALES_VW view in table format.

Copy
select * from pg_get_cols('sales') cols(view_schema name, view_name name, col_name name, col_type varchar, col_num int);