RE: Transfer Data to another tablespace with different name

From: Andre van Winssen <>
Date: Mon, 24 Nov 2008 06:34:51 +0100
Message-ID: <004e01c94df6$6020b6a0$206223e0$@com>

Hi Amir,

I believe in this case imp/exp can only help you with copying data from one TS to another. However, fromuser/touser (with each user having quota on a different default tablespace) will not work for changing PK/UK definitions to store its indexes in a different tablespace. One way that always works is to extract the PK/UK and FK ddl statements (from datadictionary or through strings|grep etc in dump file from exp), then rerun them in sqlplus (toad, whatever cli). If you run the export with CONSISTENT=Y then re-enabling FK/UK/PK should not be a problem.

Only if the new tables and PK/UK objects (ie in a different schema) use the same tablespace, then you can use the suggestion of fromuser/touser without hassle.  



From: [] On Behalf Of Amir Gheibi
Sent: maandag 24 november 2008 5:33
To: Harshan Vasudevan Eppurath
Cc: Martin Berger; ORACLE-L
Subject: Re: Transfer Data to another tablespace with different name  

Thnaks. I tried that. But it looks like that it tries to create the PKs and Indexes in the original tablespace. That's why I got a lot of 1658 errors.

IMP-00017: following statement failed with ORACLE error 1658:  "CREATE UNIQUE INDEX "PK_SKILLPREFERENCES" ON "SKILLPREFERENCES" ("ID" ) PC"
 " GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "BETATEST" LOGGING" IMP-00003: ORACLE error 1658 encountered ORA-01658: unable to create INITIAL extent for segment in tablespace BETATEST "BETATEST" is the original tablespace. As you can see it tries to create it in there and because doesn't have enough space, it comes up with that error. But why it creates it there?

here is the command I used:

imp tblspc_user/tblspc_user fromuser=betatest touser=tblspc_user file=".\desktop\a.dmp" log=".\desktop\b.log"

tblspc_user is the second user (S2) and the second tablespace is called "tblspc". Should I have logged in as Sys or system?

  • Amir

On Mon, Nov 24, 2008 at 11:58 AM, Harshan Vasudevan Eppurath <> wrote:

In that case simple export and import should do it. When importing specify  

Imp fromuser=s1 touser=s2  

You have to precreate user S2 and tablespace t2 and make default tablespace for s2 as t2.  



From: [] On Behalf Of Amir Gheibi
Sent: Monday, November 24, 2008 9:05 AM
To: Martin Berger

Subject: Re: Transfer Data to another tablespace with different name  


Thanks for the reply. The link seems very helpful. My objective is clear. There is a schema called "S1" and all of its objects are located in one tablespace called "T1". I need to make a copy of the tablespace (T1) with a different name (T2) and all the objects inside T2 be owned by another user. (Belong to another Schema; S2).

So S1's objects are all inside T1 and S2's objects are inside T2.

  • Amir

On Mon, Nov 24, 2008 at 4:22 AM, Martin Berger <> wrote:


you want to make a copy, but preserve foreign keys. And I assume, you also want to preserve the table-name?

Which one should be the one which serves the Foreign Keys?  

You also cannot have the same object twice within the same schema.  

There might be methods how to keep the same data in two tables within the same schema; I would start checking streams or Replication.  

If you want to make a copy of the tablespace, check iqueness/

maybe this will bring some inspiration ;-)  

but first, please make sure what your demand is.  

best regards,



Martin Berger  



I want to keep the original copy intact.. I want to make a copy of the

You can always use move command to put data into another tablespace and then
rename the objects


How can I transfer data from a tablespace in one db to another tablespace in
the same db?

I have Foreign Key and Sequence objects:
 - Apparently when you use IMP and you already have the structure in the
destination tablespace created, tables are not imported in the right
sequence in which the FK - PK relationships are respected and you end up
with a lot of Key violation errors. It imports the tables that have FK
objects and since it can not find the PK related to the FK, it doesn't
import the row and raise an error.

- Sequences should keep their last used values.
Does anyone have a comprehensice sholution that covers everything? I'm using 10g R2. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. --
Received on Sun Nov 23 2008 - 23:34:51 CST

Original text of this message