4

How do I list tables in redshift ?

I am using SQLWorkbench.

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

Any help?

4
  • SQL Workbench also has the WbList command: sql-workbench.net/manual/wb-commands.html#command-list Commented Aug 27, 2014 at 6:40
  • I tried WbList, it didn't give me anything useful. Has this changed in the last ~1.5 years? Commented May 12, 2016 at 20:31
  • @szeitlin "didn't give anything useful" isn't a usable problem description Commented Mar 30, 2017 at 12:11
  • @a_horse_with_no_name see my comment on the answer below. Commented Apr 1, 2017 at 10:16

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

@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.
-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;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.