Use data pump to export query results in Oracle (i) query function of data pump

Source: Internet
Author: User
Tags commit

On the itpub saw someone raise this question, can use the data pump to export a query result. In fact, the data pump really has this function.

Establish a simple test environment:


2 (ID number, NAME VARCHAR2 (30));

Table created.

Sql> INSERT into T1

2 SELECT rownum, Tname

3 from TAB;

Created rows.


2 (ID number, NAME VARCHAR2 (30));

Table created.

Sql> INSERT into T2

2 VALUES (1, ' A ');

1 row created.

Sql> INSERT into T2

2 VALUES (2, ' B ');

1 row created.


Commit complete.

If you want to export T1 and T2 query results and meet two criteria, you can consider using the Data pump query feature.

The first condition is that all the fields of the query are from the same table;

The second condition is that other tables are associated with the current table field as unique, in other words, when the current and other tables are associated, they do not produce duplicate records.

Sql> SELECT t1.* from T1, T2

2 WHERE =;


---------- ------------------------------

1 cp_test_t


This column more highlights:

For example, the above query results can be achieved through the data pump query parameters, first to query deformation, into in or exists form:

Sql> SELECT * from T1


3 (SELECT from T2 WHERE =;


---------- ------------------------------

1 cp_test_t


The following can be exported:

[oracle@yans1 ~]$ expdp test/test dumpfile=d_output:t1.dp tables=t1 query= ' T1: ' where ID in (SELECT ID from T2 WHERE = ID) "'

Export:release10. Production on Sunday, 13 June, 2010 19:52:28

Copyright (c) 2003, +, Oracle. All rights reserved.

Connected to:oracle database10genterprise Edition release10. Production

With the partitioning, OLAP and Data Mining options

Starting "TEST". " Sys_export_table_01 ": test/******** dumpfile=d_output:t1.dp tables=t1 query=t1:" Where ID in (SELECT ID from T2 WHERE t2.i D = ID) "

Estimate in progress using BLOCKS method ...

Processing Object Type Table_export/table/table_data

Total estimation using BLOCKS method:128 KB

Processing Object Type Table_export/table/table

. . Exported "TEST". " T1 "5.234 KB 2 rows

Master table "TEST". " Sys_export_table_01 "Successfully loaded/unloaded


Dump file set for TEST. SYS_EXPORT_TABLE_01 is:


Job "TEST". " Sys_export_table_01 "successfully completed at 19:52:32

This approach is simpler, but the biggest drawback is that the restrictions are too restrictive, especially if all the fields are entirely from a single table, and most of the cases cannot meet this condition.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.