List true tables only in Athena

0

I'd like to have a single query which lists all tables in a athena database excluding views.

There is

SHOW TABLES

which returns tables as well as views. I don't want to call the latter followed by a SHOW VIEWS and then separate those in my code but have that same behavior in one single call.

How can i achieve this?

gefragt vor 2 Jahren312 Aufrufe
1 Antwort
0

Hello,

Instead of SHOW TABLES, how about using the information_schema table?

SELECT * 
FROM information_schema.tables
WHERE table_schema = 'database' 

If you want to pull views separately, query the information_schema.views table.

profile pictureAWS
EXPERTE
Chris_G
beantwortet vor 2 Jahren
  • Hi, thanks for your response. That doesn't work.

    The view in my database is listed in information_schema.tables while information_schema.views is empty. How is that possible at all?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen