rp346
rp346

Reputation: 7028

list tables in redshift using SQLWorkbench

How do I list tables in redshift ?

I am using SQLWorkbench.

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

Any help?

Upvotes: 4

Views: 10261

Answers (3)

Mukul Bhardwaj
Mukul Bhardwaj

Reputation: 303

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.

Upvotes: 8

Sar009
Sar009

Reputation: 2276

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;

Upvotes: -1

Naveen Vijay
Naveen Vijay

Reputation: 16492

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

Upvotes: 2

Related Questions