How to get all the procedure name and definition in a given schema in Redshift?

こ雲淡風輕ζ 提交于 2021-01-28 18:28:56

问题


When using Redshift, I would like to get the names of all the procedure that were created in a schema, along with their definition.

I know you can use the SHOW PROCEDURE command to get the definition but that requires to have the procedure name.

In SVV_TABLE there is only information regarding tables and view but not procedure.

So if anyone knows how to get that ?


回答1:


Redshift doesn't have a system view for that yet but you can use tbe PG_PROC table and join it with pg_namespace to filter on schema name.

    select proname, proargnames, prosrc
    from PG_PROC
    join pg_namespace on pg_namespace.oid = pg_proc.pronamespace
    where nspname = 'your_schema_name' and procsecdef = true;

The procsecdef = true is to get only stored procedure definition otherwise you also get python UDF.



来源:https://stackoverflow.com/questions/59197759/how-to-get-all-the-procedure-name-and-definition-in-a-given-schema-in-redshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!