将PostgreSQL扩展安装到所有模式

我正在使用Postgresql 9.1.1尝试在所有架构上使用扩展 unaccent.

所以我运行了命令CREATE EXTENSION unaccent;.哪个有效,但仅适用于search_path上设置的当前架构.所以这意味着如果我更改search_path,我就不能再调用unaccent了.如何使此扩展可用于特定数据库中的所有模式?

提前致谢!

接受的答案是一个糟糕的建议.不要在pg_catalog架构中安装扩展.

CREATE EXTENSION unaccent;将扩展安装到公共模式中.为了实现它,只需在更改search_path时包括

set search_path = my_schema,public;

或者更好地创建包含所有扩展的模式,然后始终将该模式附加到search_path.

create schema extensions;

-- make sure everybody can use everything in the extensions schema
grant usage on schema extensions to public;
grant execute on all functions in schema extensions to public;

-- include future extensions
alter default privileges in schema extensions
   grant execute on functions to public;

alter default privileges in schema extensions
   grant usage on types to public;

现在安装扩展程序:

create extension unaccent schema extensions;

然后在search_path中使用include该模式

set search_path = my_schema,extensions;

如果您不想为您创建的每个新数据库重复上述步骤,请在连接到template1数据库时运行上述步骤.您甚至可以通过编辑postgresql.conf或使用alter system认search_path中包含扩展架构

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...