---
title: "数据库9i和10g的导入导出"
author: "quningstudy"
date: "2010-04-19T21:31:49Z"
tags: []
categories: ["数据库"]
slug: "9i-10g"
draft: false
lastmod: "2010-04-19T21:31:49Z"
id: 647794
url: "https://quningstudy.iteye.com/blog/647794"
---

一般来说，从低版本导入到高版本问题不大，麻烦的是将高版本的数据导入到低版本中，在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;       
        
  /       
  可用方法：用9i导出工具导出10g数据，并用9i导出工具导入9i 。