4

How do I list tables in redshift ?

I am using SQLWorkbench.

I tried SHOW TABLES; and \dt are not recognized commands.

Any help?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
roy
  • 6,344
  • 24
  • 92
  • 174

3 Answers3

8

On Sql workbench,

Go to Tools -> New DBexplorerWindow

it will load all the tables and click on table name shown the table schema as well

Hope this is helpfull.

Mukul Bhardwaj
  • 183
  • 1
  • 2
  • 8
2

You can use this query to get the list of tables

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

More info here - http://docs.aws.amazon.com/redshift/latest/dg/c_join_PG_examples.html

Naveen Vijay
  • 15,928
  • 7
  • 71
  • 92
  • 1
    @a_horse_with_no_name Responding to comments a year later is not helpful, either. My guess is that what I meant was, "This returned no results." But I don't remember. Because it was a year ago. – szeitlin Apr 01 '17 at 10:15
-1

This should work.

select datname, nspname, relname, sum(rows) as rows
from pg_class, pg_namespace, pg_database, stv_tbl_perm
where pg_namespace.oid = relnamespace
and pg_class.oid = stv_tbl_perm.id
and pg_database.oid = stv_tbl_perm.db_id
and datname = '**db_name**' and nspname = '**schema_name**'
group by datname, nspname, relname
order by datname, nspname, relname;
Sar009
  • 2,166
  • 5
  • 29
  • 48