How to import an oracle dump in an different tablespace ( 如何将一个包含表空间信息的dmp文件导入到另一个表空间)

Q :

I want to import an oracle dump into a different tablespace.  

I have a tablespace A used by User A. I've revoked DBA on this user and given him the grants connect and resource. Then I've dumped everything with the command

exp a/*** owner=a file=oracledump.dmp log=log.log compress=y

Now I want to import the dump into the tablespace B used by User B. So I've given him the grants on connect and resource (no DBA). Then I've executed the following import:

imp b/*** file=oracledump.dmp log=import.log fromuser=a touser=b

The result is a log with lots of errors:

IMP-00017: following statement failed with ORACLE error 20001: "BEGIN DBMS_STATS.SET_TABLE_STATS IMP-00003: ORACLE error 20001 encountered ORA-20001: Invalid or inconsistent input values

After that I've tried the same import command but with the option statistics=none. This resulted in the following errors:

ORA-00959: tablespace 'A_TBLSPACE' does not exist

How should this be done?

Note: a lot of columns are of type CLOB. It looks like the problems have something to do with that.

Note2: The oracle versions are a mixture of 9.2, 10.1 and 10.1 XE. But I don't think it has to do with versions.


Answer:

down vote accepted

You've got a couple of issues here.

Firstly, the different versions of Oracle you're using is the reason for the table statistics error - I had the same issue when some of our Oracle 10g Databases got upgraded to Release 2, and some were still on Release 1 and I was swapping .DMP files between them.

The solution that worked for me was to use the same version of exp and imp tools to do the exporting and importing on the different Database instances. This was easiest to do by using the same PC (or Oracle Server) to issue all of the exporting and importing commands.

Secondly, I suspect you're getting the ORA-00959: tablespace 'A_TBLSPACE' does not existbecause you're trying to import a .DMP file from a full-blown Oracle Database into the 10g Express Edition (XE) Database, which, by default, creates a single, predefined tablespace called USERS for you.

If that's the case, then you'll need to do the following..

  1. With your .DMP file, create a SQL file containing the structure (Tables):

    imp <xe_username>/<password>@XE file=<filename.dmp> indexfile=index.sql full=y

  2. Open the indexfile (index.sql) in a text editor that can do find and replace over an entire file, and issue the following find and replace statements IN ORDER (ignore the single quotes.. '):

    Find: 'REM<space>' Replace: <nothing>

    Find: '"<source_tablespace>"' Replace: '"USERS"'

    Find: '...' Replace: 'REM ...'

    Find: 'CONNECT' Replace: 'REM CONNECT'

  3. Save the indexfile, then run it against your Oracle Express Edition account (I find it's best to create a new, blank XE user account - or drop and recreate if I'm refreshing):

    sqlplus <xe_username>/<password>@XE @index.sql

  4. Finally run the same .DMP file you created the indexfile with against the same account to import the data, stored procedures, views etc:

    imp <xe_username>/<password>@XE file=<filename.dmp> fromuser=<original_username> touser=<xe_username> ignore=y

You may get pages of Oracle errors when trying to create certain objects such as Database Jobs as Oracle will try to use the same Database Identifier, which will most likely fail as you're on a different Database.


down vote accepted

You've got a couple of issues here.

Firstly, the different versions of Oracle you're using is the reason for the table statistics error - I had the same issue when some of our Oracle 10g Databases got upgraded to Release 2, and some were still on Release 1 and I was swapping .DMP files between them.

The solution that worked for me was to use the same version of exp and imp tools to do the exporting and importing on the different Database instances. This was easiest to do by using the same PC (or Oracle Server) to issue all of the exporting and importing commands.

Secondly, I suspect you're getting the ORA-00959: tablespace 'A_TBLSPACE' does not existbecause you're trying to import a .DMP file from a full-blown Oracle Database into the 10g Express Edition (XE) Database, which, by default, creates a single, predefined tablespace called USERS for you.

If that's the case, then you'll need to do the following..

  1. With your .DMP file, create a SQL file containing the structure (Tables):

    imp <xe_username>/<password>@XE file=<filename.dmp> indexfile=index.sql full=y

  2. Open the indexfile (index.sql) in a text editor that can do find and replace over an entire file, and issue the following find and replace statements IN ORDER (ignore the single quotes.. '):

    Find: 'REM<space>' Replace: <nothing>

    Find: '"<source_tablespace>"' Replace: '"USERS"'

    Find: '...' Replace: 'REM ...'

    Find: 'CONNECT' Replace: 'REM CONNECT'

  3. Save the indexfile, then run it against your Oracle Express Edition account (I find it's best to create a new, blank XE user account - or drop and recreate if I'm refreshing):

    sqlplus <xe_username>/<password>@XE @index.sql

  4. Finally run the same .DMP file you created the indexfile with against the same account to import the data, stored procedures, views etc:

    imp <xe_username>/<password>@XE file=<filename.dmp> fromuser=<original_username> touser=<xe_username> ignore=y

You may get pages of Oracle errors when trying to create certain objects such as Database Jobs as Oracle will try to use the same Database Identifier, which will most likely fail as you're on a different Database.

转载自:http://stackoverflow.com/questions/61963/howto-import-an-oracle-dump-in-an-different-tablespace

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值