Show tables, describe tables equivalent in redshift

sas picture sas · Sep 11, 2013 · Viewed 111.2k times · Source

I'm new to aws, can anyone tell me what are redshifts' equivalents to mysql commands?

show tables -- redshift command
describe table_name -- redshift command

Answer

Tomasz Tybulewicz picture Tomasz Tybulewicz · Sep 11, 2013

All the information can be found in a PG_TABLE_DEF table, documentation.

Listing all tables in a public schema (default) - show tables equivalent:

SELECT DISTINCT tablename
FROM pg_table_def
WHERE schemaname = 'public'
ORDER BY tablename;

Description of all the columns from a table called table_name - describe table equivalent:

SELECT *
FROM pg_table_def
WHERE tablename = 'table_name'
AND schemaname = 'public';