我需要为PostgreSQL数据库对象创建脚本
我没有进入pg_垃圾场的权限。因此,我必须使用SQL查询获取所有信息。我怎么能这样做
要获取函数的定义,请使用pg\u get\u functiondef():
选择pg_get_functiondef(oid)
从pg_程序
其中proname='foo';
有类似的函数来检索索引、视图、规则等的定义。有关详细信息,请参阅手册:http://www.postgresql.org/docs/current/static/functions-info.html
获取用户类型的定义有点棘手。您需要查询信息\u schema.attributes:
选择属性名称、数据类型
来自信息\u schema.attributes
其中udt_模式='public'
udt_name='footype'
按顺序排列;
因此,您需要重新组合create type语句
有关更多详细信息,您需要阅读系统目录的文档:http://www.postgresql.org/docs/current/static/catalogs.html
但是如果视图返回相同的信息,您应该更喜欢information\u schema视图