Iharob Al Asimi
Iharob Al Asimi

Reputation: 53006

Get all the tables involved in a SELECT query in PostgreSQL using `libpq'

Is it possible to get the names or (Oid's) for all queried tables with libpq? If there exists a generic standard SQL way i would prefer it.

Upvotes: 0

Views: 312

Answers (1)

Dmitri Goldring
Dmitri Goldring

Reputation: 4363

It's not standard, but the Postgres EXPLAIN command can give you (more than) what you want.

http://www.postgresql.org/docs/9.3/static/sql-explain.html

If you use the JSON output format, the table names are found in the "Relation Name" attributes of the "Plan" objects.

Upvotes: 4

Related Questions