oracle - 在 PostgreSQL 上使用扩展名 orafce 安装的模式

标签 oracle postgresql orafce

我在 PostgreSQL 9.5 上安装了 orafce 扩展。我看到最好为所有扩展创建一个特定的模式,这就是我所做的。我连接到模板 1 并执行了下一个命令:

template1=# create schema extensions;
CREATE SCHEMA
template1=# grant usage on schema extensions to public;
GRANT
template1=# grant execute on all functions in schema extensions to public;
GRANT
template1=# alter default privileges in schema extensions grant execute on             
functions to public;
ALTER DEFAULT PRIVILEGES
template1=# alter default privileges in schema extensions grant usage on     
types to public;
ALTER DEFAULT PRIVILEGES
template1=# create extension orafce schema extensions;
CREATE EXTENSION
template1=# show search_path;
search_path
 -----------------
"$user", public
(1 row)

template1=# set search_path="$user",public,extensions;
SET

之后我创建了一个新数据库 test1 和一个新用户 mariel1。此外,我编辑了 postgresql.conf 并将 search_path 设置为“$user”,public,extensions。

我连接到数据库 - psql -d test1 -U mariel1。现在,当我尝试使用函数 sysdate 时,例如数据库无法识别该函数:

postgres=# select sysdate() from dual;
ERROR:  function sysdate() does not exist
LINE 1: select sysdate() from dual;
           ^
HINT:  No function matches the given name and argument types. You might need     
to add explicit type casts.
postgres=# select extensions.sysdate() from dual;
ERROR:  schema "extensions" does not exist
LINE 1: select extensions.sysdate() from dual;

经过一番搜索后,我发现一些函数在其他模式(如 oracle、utl_file 等)下可用。我想了解为什么 orafce 的功能(oracle.sysdate 等...)是在不同的架构(oracle、utl_file..)下创建的,而不是在我的新架构扩展下创建的。

最佳答案

PostgreSQL 中的扩展是数据库 级别,而不是架构级别或实例级别。您不能在同一数据库中创建相同的扩展。但是您可以在多个数据库中创建相同的扩展名。这就是 PostgreSQL 中扩展的工作方式。

关于oracle - 在 PostgreSQL 上使用扩展名 orafce 安装的模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44919833/

相关文章:

mysql - SQL 中的条件概率 p(y|x)

postgresql - Ubuntu 中 PostgreSQL 数据库的自动备份

oracle - 收集2 : fatal error: cannot find 'ld' when executing make install

java - 如何使用 JPA/Hibernate 在 child 的 id 中引用 parent 的 id?

c# - 查看数据库中的数据与 EF 生成的不同

Java double 据类型不应该用于精确值,例如货币?

sql - Oracle 排序依据 - 基于函数 (dense_rank)

postgresql - 我如何销毁 PostgreSQL 中模式的所有表