0

How can I find the number of User-defined functions and Stored Procedures in PostgreSQL database?

3 Answers 3

1

It will work for you :

(editted by @a_horse_with_no_name 's warn)

SELECT count(*)
FROM information_schema.routines
WHERE routines.specific_schema='schema_name'
Sign up to request clarification or add additional context in comments.

1 Comment

oohh you are so right. I am editing the answer, sorry.
1

This excludes metadata schemas of postgres:

select count(*) from information_schema.routines t where t.routine_schema not in ('pg_catalog', 'information_schema');

If you're only interested in the number of procedures then:

select count(*) from information_schema.routines t where t.routine_schema not in ('pg_catalog', 'information_schema') and t.routine_type = 'PROCEDURE';

Comments

0

If you want the list of procedures and functions with schema then you can use

SELECT specific_schema,routine_name, routine_type
FROM information_schema.routines
where specific_schema ='Schema_name'

and if you want just a count of procedures and functions then you can use

SELECT count(*)
FROM information_schema.routines
where specific_schema ='Schema_name'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.