Re: PG query to count all objects
От
Ashutosh Sharma
Тема
Re: PG query to count all objects
Дата
Msg-id
CAE9k0PnCQfKgBTUW5eVNw7-AzYC9jdgMh8df7ADKwWg34Fa6Dg@mail.gmail.com
Ответ на
PG query to count all objects (Prashant Kulkarni)
Список
Дерево обсуждения
PG query to count all objects Prashant Kulkarni <ppk10.prashant@gmail.com>
Re: PG query to count all objects Ashutosh Sharma <ashu.coek88@gmail.com>
Hi Prashant,
You may try running the following SQL query.
select
n.nspname as schema_name
,c.relname as object_name
,r.rolname as object_owner
,case c.relkind
when 'r' then 'TABLE'
when 'm' then 'MATERIALIZED_VIEW'
when 'i' then 'INDEX'
when 'S' then 'SEQUENCE'
when 'v' then 'VIEW'
when 'c' then 'TYPE'
else c.relkind::text
end as object_type
from pg_class c
join pg_roles r
on r.oid = c.relowner
join pg_namespace n
on n.oid = c.relnamespace
where n.nspname not in ('information_schema', 'pg_catalog')
and n.nspname not like 'pg_toast%'
order by n.nspname, c.relname;
n.nspname as schema_name
,c.relname as object_name
,r.rolname as object_owner
,case c.relkind
when 'r' then 'TABLE'
when 'm' then 'MATERIALIZED_VIEW'
when 'i' then 'INDEX'
when 'S' then 'SEQUENCE'
when 'v' then 'VIEW'
when 'c' then 'TYPE'
else c.relkind::text
end as object_type
from pg_class c
join pg_roles r
on r.oid = c.relowner
join pg_namespace n
on n.oid = c.relnamespace
where n.nspname not in ('information_schema', 'pg_catalog')
and n.nspname not like 'pg_toast%'
order by n.nspname, c.relname;
On Thu, Apr 2, 2020 at 2:19 PM Prashant Kulkarni <ppk10.prashant@gmail.com> wrote:
Hi Team,Please can you help me with a query in PostgreSQL which will list the count of all objects in the database with respect (group by) object types( Table/ Index/Mview/Partition/Subpartition/Sequece/Lob/Procedure/Functions/..../etc)Thanks.
В списке pgsql-admin по дате отправления
От: postgann2020 s
Дата: