pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDisplay View Columns and Their Source Tables and Columns
3+ messages / 3 participants
[nested] [flat]
* Display View Columns and Their Source Tables and Columns
@ 2019-04-21 19:33 Susan Hurst <susan.hurst@brookhurstdata.com>
0 siblings, 2 replies; 3+ messages in thread
From: Susan Hurst @ 2019-04-21 19:33 UTC (permalink / raw)
To: Discuss List Postgres <pgsql-general@lists.postgresql.org>
I'm so close but I can't quite figure out how to match view columns to
their source columns in a query. Looks like I might need yet another
table to join that makes that match, but I'm not having any success
finding such a bridge. Matching views to their source tables works well
enough. What am I missing? Is there a better approach?
I would welcome any comments or leads that you have.
Thanks for your help!
Sue
Here is what I have so far:
select vcu.view_name view_name
,c.column_name view_column
,vcu.table_schema source_schema
,vcu.table_name source_table
,vcu.column_name source_column
,c.is_updatable is_updatable
from information_schema.view_column_usage vcu
,information_schema.columns c
where vcu.view_schema = 'devops'
and vcu.table_schema in ('devops','chief','store')
and vcu.view_schema = c.table_schema
and vcu.view_name = c.table_name
and ************************ Help! *****************
order by vcu.view_name
,vcu.table_name
,c.column_name
;
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Susan E Hurst
Principal Consultant
Brookhurst Data LLC
Email: susan.hurst@brookhurstdata.com
Mobile: 314-486-3261
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Display View Columns and Their Source Tables and Columns
@ 2019-04-21 21:51 legrand legrand <legrand_legrand@hotmail.com>
parent: Susan Hurst <susan.hurst@brookhurstdata.com>
1 sibling, 0 replies; 3+ messages in thread
From: legrand legrand @ 2019-04-21 21:51 UTC (permalink / raw)
To: pgsql-general
Hi,
I don't know if it is possible ...
the only way I found seems to use pg_depend and pg_rewrite
as described here
https://pgdba.org/post/2018/04/dependency_ladder/
Regards
PAscal
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Display View Columns and Their Source Tables and Columns
@ 2019-04-21 22:25 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Susan Hurst <susan.hurst@brookhurstdata.com>
1 sibling, 0 replies; 3+ messages in thread
From: Laurenz Albe @ 2019-04-21 22:25 UTC (permalink / raw)
To: susan.hurst@brookhurstdata.com; Discuss List Postgres <pgsql-general@lists.postgresql.org>
Susan Hurst wrote:
> I'm so close but I can't quite figure out how to match view columns to
> their source columns in a query.
There is no simple way to find which view column matches which column
in the original table. Don't forget that the column could be defined
as an expression that involves several columns of the base table.
You'd have to parse pg_rewrite.ev_action.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-04-21 22:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-04-21 19:33 Display View Columns and Their Source Tables and Columns Susan Hurst <susan.hurst@brookhurstdata.com>
2019-04-21 21:51 ` legrand legrand <legrand_legrand@hotmail.com>
2019-04-21 22:25 ` Laurenz Albe <laurenz.albe@cybertec.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox