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 <ppk10.prashant@gmail.com>)
Список pgsql-admin
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;

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

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 по дате отправления:

Предыдущее
От: Prashant Kulkarni
Дата:
Сообщение: PG query to count all objects
Следующее
От: postgann2020 s
Дата:
Сообщение: Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables