Sql developer如何通过Sql Export Pump获取带序列的表

时间:2017-03-08 09:26:16

标签: oracle-sqldeveloper

在sql developer数据泵导出中我想用它的顺序导出表。数据泵"导出向导"我如何使用过滤器选项"启用包含或排除过滤器"。

1 个答案:

答案 0 :(得分:0)

不确定是否可以使用SQL Developer工具本身执行此操作,但这是通过命令行执行此操作:
在测试模式中创建了一些测试对象(TEST_EXP_OBJECTS):

public function testListaDisciplinas()
{
    $this->auth();
    // simulate the repository to not modify the db
    $disciplinaRepository = $this->getMock('Domain\Model\Disciplina\DisciplinaRepository');

    $em = $this->getApplicationServiceLocator()->get('Doctrine\ORM\EntityManager');

    $query = $em->createQueryBuilder();
    $query->select('d')
          ->from('Domain\Model\Disciplina\Disciplina', 'd')
          ->setMaxResults(1);

    $disciplinaRepository->method('getByProfessorTutor')
                         ->willReturn(new Paginator($query, $fetchJoinCollection = false));

    $serviceManager = $this->getApplicationServiceLocator();
    $serviceManager->setAllowOverride(true);
    $serviceManager->setService('DisciplinaRepository', $disciplinaRepository);
    $result = $this->dispatch('/uov/professor/disciplinas');
    $this->assertResponseStatusCode(200);
}

然后创建了一个测试目录:

CREATE SEQUENCE TEST_EXP_OBJECTS.TEST_SEQUENCE;
CREATE TABLE TEST_EXP_OBJECTS.TEST_TABLE AS 
SELECT * FROM DBA_USERS WHERE ROWNUM<2;

然后expdp引用架构,特定表名和特定序列名称的对象:

SQL> create directory test_exp_dir as '/home/oracle';

Directory created.

expdp的输出:

expdp schemas=TEST_EXP_OBJECTS \
include=sequence:\"= \'TEST_SEQUENCE\'\" \
include=table:\"= \'TEST_TABLE\'\" \
directory=test_exp_dir \
logfile=test.log \
dumpfile=test.dmp

让我们创建一个测试模式(REIMPORT_TEST_SCHEMA),impdp,并验证数据和序列:

Export: Release 11.2.0.4.0 - Production on Thu Mar 9 08:32:48 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Username: ***

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_SCHEMA_01":  /******** AS SYSDBA schemas=TEST_EXP_OBJECTS include=sequence:"= include include=table:"= include directory=test_exp_dir logfile=test.log dumpfile=test.dmp

Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 104 KB
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "TEST_EXP_OBJECTS"."TEST_TABLE"             10.82 KB       1 rows
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/test.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at Thu Mar 9 08:33:47 2017 elapsed 0 00:00:56

清理我们的烂摊子:

oracle@EBS-G2-DB01:/home/oracle> impdp dumpfile=test.dmp logfile=test.log remap_schema=TEST_EXP_OBJECTS:REIMPORT_TEST_SCHEMA directory=test_exp_dir

Import: Release 11.2.0.4.0 - Production on Thu Mar 9 08:39:50 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Username: / as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":  /******** AS SYSDBA dumpfile=test.dmp logfile=test.log remap_schema=TEST_EXP_OBJECTS:REIMPORT_TEST_SCHEMA directory=test_exp_dir
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "REIMPORT_TEST_SCHEMA"."TEST_TABLE"         10.82 KB       1 rows
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at Thu Mar 9 08:39:54 2017 elapsed 0 00:00:01

oracle@EBS-G2-DB01:/home/oracle> !sql
sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 9 08:39:57 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select object_name, owner from all_objects where owner='REIMPORT_TEST_SCHEMA';

OBJECT_NAME                    OWNER
------------------------------ ------------------------------
TEST_SEQUENCE                  REIMPORT_TEST_SCHEMA
TEST_TABLE                     REIMPORT_TEST_SCHEMA

SQL> select count(*) from REIMPORT_TEST_SCHEMA.test_table;

  COUNT(*)
----------
         1

SQL>