top of page

SQL developer for PostgreSQL

Открытая·2 пользователя

PostgreSQL: table depend (Where is used)



[EN]

The node shows the dependency relationships between the selected table and database objects


Output information

  • Object name

  • Object type

  • List of used table columns


SELECT v.oid::regclass::text "name", v.oid,

a.attname,

case

when v.relkind = 'v' then 'view'

when v.relkind = 'r' then 'table'

when v.relkind = 'i' then 'index'

when v.relkind = 't' then 'toast table'

when v.relkind = 'S' then 'sequence'

when v.relkind = 'm' then 'materialized view'

when v.relkind = 'c' then 'composite'

when v.relkind = 'f' then 'foreign'

end "relkind" ,

case

when deptype = 'n' then 'DEPENDENCY_NORMAL'

when deptype = 'a' then 'DEPENDENCY_AUTO'

when deptype = 'i' then 'DEPENDENCY_INTERNAL'

when deptype = 'P' then 'DEPENDENCY_PARTITION_PRI'

when deptype = 'S' then 'DEPENDENCY_PARTITION_SEC'

when deptype = 'e' then 'DEPENDENCY_EXTENSION'

when deptype = 'x' then 'DEPENDENCY_AUTO_EXTENSION'

when deptype = 'p' then 'DEPENDENCY_PIN'

end "deptype"

FROM pg_depend d

JOIN pg_rewrite r ON r.oid = d.objid

JOIN pg_class v ON v.oid = r.ev_class

LEFT JOIN pg_attribute a on (a.attnum = d.refobjsubid and a.attrelid = v.oid )

WHERE d.refobjid = $$TABLEOID


[RU]

Узел показывает отношения зависимости между выбранной таблицей и объектами базы данных


Выводимая информация

  • Имя объекта

  • Тип объекта

  • Список используемых колонок таблицы


SELECT v.oid::regclass::text "name", v.oid,

a.attname,

case

when v.relkind = 'v' then 'view'

when v.relkind = 'r' then 'table'

when v.relkind = 'i' then 'index'

when v.relkind = 't' then 'toast table'

when v.relkind = 'S' then 'sequence'

when v.relkind = 'm' then 'materialized view'

when v.relkind = 'c' then 'composite'

when v.relkind = 'f' then 'foreign'

end "relkind" ,

case

when deptype = 'n' then 'DEPENDENCY_NORMAL'

when deptype = 'a' then 'DEPENDENCY_AUTO'

when deptype = 'i' then 'DEPENDENCY_INTERNAL'

when deptype = 'P' then 'DEPENDENCY_PARTITION_PRI'

when deptype = 'S' then 'DEPENDENCY_PARTITION_SEC'

when deptype = 'e' then 'DEPENDENCY_EXTENSION'

when deptype = 'x' then 'DEPENDENCY_AUTO_EXTENSION'

when deptype = 'p' then 'DEPENDENCY_PIN'

end "deptype"

FROM pg_depend d

JOIN pg_rewrite r ON r.oid = d.objid

JOIN pg_class v ON v.oid = r.ev_class

LEFT JOIN pg_attribute a on (a.attnum = d.refobjsubid and a.attrelid = v.oid )

WHERE d.refobjid = $$TABLEOID


5 просмотров

О группе

Добро пожаловать в группу! Общайтесь с другими участниками, получайте обновления и делитесь фото и видео.

Участники

bottom of page