一般來說,從低版本匯入到高版本問題不大,麻煩的是將高版本的資料匯入到低版本中,在Oracle9i之前,不同版本Oracle之間的EXP/IMP可以通過下面的方法來解決:
1、在高版本資料庫上運行底版本的catexp.sql;
2、使用低版本的EXP來匯出高版本的資料;
3、使用低版本的IMP將資料庫匯入到底版本資料庫中;
4、在高版本資料庫上重新運行高版本的catexp.sql指令碼。
但在9i中,上面的方法並不能解決問題。如果直接使用底版本EXP/IMP會出現如下錯誤:
EXP-00008: ORACLE error %lu encountered
ORA-00904: invalid column name
這已經是一個公布的BUG,需要等到Oracle10.0才能解決,BUG號為2261722,你可以到METALINK上去查看有關此BUG的詳細資料。
BUG歸BUG,我們的工作還是要做,在沒有Oracle的支援之前,我們就自己解決。在Oracle9i中執行下面的SQL重建exu81rls視圖即可。
CREATE OR REPLACE view exu81rls
(objown,objnam,policy,polown,polsch,polfun,stmts,chkopt,enabled,spolicy)
AS select u.name, o.name, r.pname, r.pfschma, r.ppname, r.pfname,
decode(bitand(r.stmt_type,1), 0,'', 'SELECT,')
|| decode(bitand(r.stmt_type,2), 0,'', 'INSERT,')
|| decode(bitand(r.stmt_type,4), 0,'', 'UPDATE,')
|| decode(bitand(r.stmt_type,8), 0,'', 'DELETE,'),
r.check_opt, r.enable_flag,
DECODE(BITAND(r.stmt_type, 16), 0, 0, 1)
from user$ u, obj$ o, rls$ r
where u.user# = o.owner#
and r.obj# = o.obj#
and (uid = 0 or
uid = o.owner# or
exists ( select * from session_roles where role='SELECT_CATALOG_ROLE')
)
/
grant select on sys.exu81rls to public;
/