postgresql 从 Postgres 数据库中删除所有函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10591113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Drop all functions from Postgres database
提问by Jim Mitchener
I have a database with an old broken version of PostGIS installed in it. I would like to easily drop all functions in the database (they're all from PostGIS). Is there a simple way to do this? Even simply extracting a list of function names would be acceptable as I could just make a large DROP FUNCTION
statement.
我有一个安装了旧的损坏版本的 PostGIS 的数据库。我想轻松删除数据库中的所有函数(它们都来自 PostGIS)。有没有一种简单的方法可以做到这一点?即使只是简单地提取一个函数名称列表也是可以接受的,因为我可以做一个大DROP FUNCTION
声明。
回答by ChristopheD
A fine answer to this question can be found here:
SELECT 'DROP FUNCTION ' || ns.nspname || '.' || proname
|| '(' || oidvectortypes(proargtypes) || ');'
FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid)
WHERE ns.nspname = 'my_messed_up_schema' order by proname;
回答by Mike T
Just as there was a postgis.sql
enabler install script, there is also an uninstall_postgis.sql
uninstall script.
就像有一个postgis.sql
启用程序安装脚本一样,还有一个uninstall_postgis.sql
卸载脚本。
psql -d [yourdatabase] -f /path/to/uninstall_postgis.sql
Warning: Be prepared to see your geometry/geography columns and data disappear!
警告:准备好看到您的几何/地理列和数据消失!