Greenplum的Oracle兼容性函數(shù)安裝

許多Oracle的SQL函數(shù)可以應用到Greenplum數(shù)據(jù)庫中。Greenplum默認安裝完成后并不能使用Oracle的兼容性函數(shù)。

template1=# select nvl(null,2);

ERROR: function nvl(unknown, integer) does not exist

LINE 1: select nvl(null,2);

在使用任何Oracle兼容函數(shù)之前,你必須為每個數(shù)據(jù)庫執(zhí)行下面的安裝腳本(示例為testdb數(shù)據(jù)庫):

psql -d testdb -f $GPHOME/share/postgresql/contrib/orafunc.sql

當然你也可以卸載Oracle函數(shù):

psql -d testdb -f $GPHOME/share/postgresql/contrib/uninstall_orafunc.sql

安裝完成后,如果直接在testdb數(shù)據(jù)庫中使用還會找不到Oracle的相關(guān)函數(shù),比如:

testdb=# select nvl(null,8);

ERROR: function nvl(unknown, integer) does not exist

LINE 1: select nvl(null,8);

^

HINT: No function matches the given name and argument types. You may need to add explicit type casts.

我們查看schema是搜索路徑:

testdb=# show search_path ;

search_path

----------------

"$user",public

Oracle的兼容函數(shù)都安裝在oracompat的schema下面。為了訪問這些Oracle函數(shù),可以指定oracompat前綴或者修改數(shù)據(jù)庫的搜索路徑:

ALTER DATABASE testdb SET search_path = "$user", public, oracompat;

然后重新登錄Greenplum環(huán)境:

[gpadmin@cdha postgresql]$ psql -d testdb

psql (8.2.15)

Type "help" for help.

testdb=# select nvl(null,8);

nvl

-----

8

可以看到Greenplum中可以正常使用Oracle的兼容函數(shù)了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容