How to view user-defined stored procedures in PostgreSQL
Recently I’ve frequently been finding myself needing to look up details of custom stored procedures in PostgreSQL databases. Here are a few helpful queries for that.
First, a simple list of the queries:
SELECT n.nspname AS schema, p.proname AS procedure FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid WHERE n.nspname NOT IN ('pg_catalog', 'information_schema') AND p.prokind = 'p';
Second, the owner of the procedures:
SELECT proname, proowner::regrole FROM pg_proc WHERE pronamespace::regnamespace::text = 'public';