Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of external schemas and tables from Amazon Redshift

I have created external schema and external table in Redshift. I'm able to see external schema name in postgresql using \dn.

What will be query to do it so that i can run it in java? and also the query to get list of external table?

I tried

select * from information_schema.tables where 
table_schema not in ('pg_catalog', 'information_schema') 
and table_schema not like 'pg_toast%' 

but it didn't get the list of external tables.

like image 610
mayank singh Avatar asked Jun 17 '18 08:06

mayank singh


People also ask

What are external schemas in Redshift?

In Amazon Redshift, we use the term schema. An Amazon Redshift external schema references an external database in an external data catalog. You can create the external database in Amazon Redshift, in Amazon Athena, in AWS Glue Data Catalog, or in an Apache Hive metastore, such as Amazon EMR.

How do you find the external table structure in Redshift?

Use SVV_EXTERNAL_TABLES to view details for external tables; for more information, see CREATE EXTERNAL SCHEMA. Use SVV_EXTERNAL_TABLES also for cross-database queries to view metadata on all tables on unconnected databases that users have access to. SVV_EXTERNAL_TABLES is visible to all users.

How do you see all Redshift tables?

In order to list or show all of the tables in a Redshift database, you'll need to query the PG_TABLE_DEF systems table. An interesting thing to note is the PG_ prefix. This is because Redshift is based off Postgres, so that little prefix is a throwback to Redshift's Postgres origins.

What are external schemas?

External Schema/Level An external schema describes the part of the database which specific user is interested in. It hides the unrelated details of the database from the user. There may be “n” number of external views for each database.


1 Answers

Redshift Spectrum external databases, schemas, and tables have their own catalog views.

  • SVV_EXTERNAL_DATABASES
  • SVV_EXTERNAL_SCHEMAS
  • SVV_EXTERNAL_TABLES
  • SVV_EXTERNAL_PARTITIONS
  • SVV_EXTERNAL_COLUMNS

You can query these from any connection: SELECT * FROM svv_external_schemas;

like image 193
Joe Harris Avatar answered Sep 18 '22 15:09

Joe Harris