Show tables, describe tables equivalent in redshift

79

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

This question is tagged with amazon-web-services amazon-redshift

~ Asked on 2013-09-11 05:36:11

The Best Answer is


106

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';

~ Answered on 2013-09-11 11:37:41


83

I had to select from the information schema to get details of my tables and columns; in case it helps anyone:

SELECT * FROM information_schema.tables
WHERE table_schema = 'myschema'; 

SELECT * FROM information_schema.columns
WHERE table_schema = 'myschema' AND table_name = 'mytable'; 

~ Answered on 2015-01-07 16:56:24


Most Viewed Questions: