List stored functions that reference a table in PostgreSQL

后端 未结 9 1076
深忆病人
深忆病人 2020-12-07 14:10

Just a quick and simple question: in PostgreSQL, how do you list the names of all stored functions/stored procedures using a table using just a SELECT statement, if possible

9条回答
  •  Happy的楠姐
    2020-12-07 14:53

    Same as @quassnoi and @davidwhthomas, except I added the argument names in there:

    SELECT  proname, proargnames, prosrc 
    FROM    pg_catalog.pg_namespace n
    JOIN    pg_catalog.pg_proc p
    ON      pronamespace = n.oid
    WHERE   nspname = 'public';
    

    If the purpose behind listing the functions is to clean them up or iterate a new function with a changing params list, you will frequently need to drop functions:

    DROP FUNCTION ();
    

    By adding proargnames, I am able to construct the applicable function name for the drop.

    Additionally, it's nice to see a more complete picture when evaluating the functions.

提交回复
热议问题