Reputation: 7028
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
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
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
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