viernes, 3 de agosto de 2018

List views of a table

select
    dependent_ns.nspname as dependent_schema,
    dependent_view.relname as dependent_view,
    source_ns.nspname as source_schema,
    source_table.relname as source_table,
    pg_attribute.attname as column_name
from
    pg_depend
join pg_rewrite on
    pg_depend.objid = pg_rewrite.oid
join pg_class as dependent_view on
    pg_rewrite.ev_class = dependent_view.oid
join pg_class as source_table on
    pg_depend.refobjid = source_table.oid
join pg_attribute on
    pg_depend.refobjid = pg_attribute.attrelid
    and pg_depend.refobjsubid = pg_attribute.attnum
join pg_namespace dependent_ns on
    dependent_ns.oid = dependent_view.relnamespace
join pg_namespace source_ns on
    source_ns.oid = source_table.relnamespace
where
    source_ns.nspname = 'adempiere'
    and source_table.relname = 'a_asset'
    and pg_attribute.attnum > 0
    and pg_attribute.attname = 'name'
order by
    1,
    2;


Result:

No hay comentarios:

Publicar un comentario