Solved

Oracle Export Utility, with where conditions to export only a part of the table data

Posted on 2008-10-23
9
1,428 Views
Last Modified: 2013-12-18
The Oracle User called QUIZ contains the table called CITY has over 2 million records.
This table has 20 columns, no importance for their names.
Please suppose that 3 columns of 20 are the following:

a) DAYS of type DATE;
b) SUN of type NUMBER;
c) RAIN of type VARCHAR2(50).

We would like to create a PARTIAL COPY of this table in another Oracle user called HISTORICAL, fetching only the records with:

a) DAYS >= to_date('01/01/2007','DD/MM/YYYY');
b) SUN >= 3;
c) RAIN beginning with the string 'SHARK'

I think it's too heavy to open a cursor on the source table, inserting record for record if satisfying the three conditions, so I would like to use the export utility with a file containing the conditions.

Could you please help me?
0
Comment
Question by:hc2342uhxx3vw36x96hq
9 Comments
 
LVL 2

Assisted Solution

by:stanimirp
stanimirp earned 20 total points
ID: 22784305
0
 
LVL 1

Author Comment

by:hc2342uhxx3vw36x96hq
ID: 22784413
Sorry, I need the answer to MY question, not a link to general definition of export utility.
0
 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 250 total points
ID: 22784650
I think you can simple do a INSERT INTO ... SELECT
HISTORICAL should have read access to CITY table of QUIZ.

insert /*+ APPEND */ into HISTORICAL.CITY
select * from QUIZ.CITY
where DAYS >= to_date('01/01/2007','DD/MM/YYYY') and SUN >= 3 and RAIN like 'SHARK%';

If you MUST go for sql loader here is the command.
exp username/pwd tables=CITY file=dump_file_name.dmp QUERY='where DAYS >= to_date(''01/01/2007'',''DD/MM/YYYY'') and SUN >= 3 and RAIN like ''SHARK%'''
0
 
LVL 1

Author Comment

by:hc2342uhxx3vw36x96hq
ID: 22784848
sujith80, with your exp command, can I import the table CITY into a different tablespace owned by the HISTORICAL Oracle user?

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 250 total points
ID: 22784959
>>  into a different tablespace
Yes, create the table in a differnt tablespace before the import and run the import with ignore=Y
0
 
LVL 1

Author Comment

by:hc2342uhxx3vw36x96hq
ID: 22785175
C:\>exp user/password@SID

Export: Release 10.2.0.3.0 - Production on Thu Oct 23 14:05:46 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


EXP-00056: ORACLE error 6550 encountered
ORA-06550: line 1, column 41:
PLS-00302: component 'SET_NO_OUTLINES' must be declared
ORA-06550: line 1, column 15:
PL/SQL: Statement ignored
EXP-00000: Export terminated unsuccessfully

0
 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 250 total points
ID: 22787805
Contact your dba
0
 
LVL 2

Accepted Solution

by:
barfi earned 230 total points
ID: 22787827
If you are trying to IMPORT object owned by a user into different tablespace- try  using DataPump in10g. This works great without creating any thing. There is a parameter called REMAP_TABLESPACE- USING THIS PARAMETER you can create the objects that belong to a tablespace in the source to another in the target. Syntax is:
Remap_Tablespace=source_tablespace:target_tablespace
 So for example if you need to import objects owned by user1 and are stored in user1_tblspace with data pump you ca import these objects to the different tablespace user1_tblspace. Here is the command:
Syntax:
impdp directory+mydumpdir dumpfile=abc.dmp
remap_schema=user1:user2
above command will create all the objects owned by user1 in user2 schema
but in your case do this:
remap_tablespace=user1tblspace:user2_tablespace
This works if you try to do it thru GUI (OEM) but you have to set directory and authenticate it (read-write privliges). It is one time work but I bet you will not go back to old exp/emp utilities once you use the DATAPUMP in 10g.
Hope it helps...
here is the simple link for all the parameters also:
http://www.oracle-base.com/articles/10g/OracleDataPump10g.php

0
 
LVL 1

Author Closing Comment

by:hc2342uhxx3vw36x96hq
ID: 31509120
Thank you!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now