Oracle expdp導出分區表,query條件帶有rownum


 

Oracle expdp導出分區表,query條件帶有rownum

前言

在做數據脫敏的時候,對一張剛好是分區表的表做導出,為了只取出部分數據看是否數據可以正常脫敏,在query中帶上rownum。

結果發現是每個分區都取出了rownum的限定行數。

比如:rownum<=5,正常去查詢表的話是只會有5行的結果,

但是expdp導出分區表,帶rownum<=5,則是每個分區都取出符合條件的5行。

這應該算BUG吧?

 

環境模擬

構造分區表

create table scott.t_partition_range (id number)
partition by range(id)(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition pmax values less than (maxvalue)
);
模板復制

 

SYS@zkm> create table scott.t_partition_range (id number)
  2  partition by range(id)(
  3  partition p1 values less than (10),
  4  partition p2 values less than (20),
  5  partition p3 values less than (30),
  6  partition pmax values less than (maxvalue)
  7  );

Table created.

 

插入數據

begin 
  for i in 1..50 loop
    insert into scott.t_partition_range values(i);
  end loop;
  commit;
end;
/
模板復制
SYS@zkm> begin 
  2    for i in 1..50 loop
  3      insert into scott.t_partition_range values(i);
  4    end loop;
  5    commit;
  6  end;
  7  /

PL/SQL procedure successfully completed.

 

查詢數據示例

SYS@zkm> select * from scott.t_partition_range partition(p1);

        ID
----------
         1
         2
         3
         4
         5
         6
         7
         8
         9

9 rows selected.

SYS@zkm> select * from scott.t_partition_range partition(p2);

        ID
----------
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19

10 rows selected.

SYS@zkm> select * from scott.t_partition_range partition(pmax);

        ID
----------
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40

        ID
----------
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50

21 rows selected.

SYS@zkm> select * from scott.t_partition_range where rownum<=5;

        ID
----------
         1
         2
         3
         4
         5

 

 

數據泵導出

[oracle@oracle ~]$ expdp \' / as sysdba \' directory=dir dumpfile=test.dmp logfile=test.log reuse_dumpfiles=y cluster=n tables=scott.t_partition_range query=scott.t_partition_range:\"where rownum\<=5\" 

Export: Release 11.2.0.4.0 - Production on Thu May 14 02:24:57 2020

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  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
Starting "SYS"."SYS_EXPORT_TABLE_01":  "/******** AS SYSDBA" directory=dir dumpfile=test.dmp logfile=test.log reuse_dumpfiles=y cluster=n tables=scott.t_partition_range query=scott.t_partition_range:"where rownum<=5" 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 32 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."T_PARTITION_RANGE":"P1"            5.046 KB       5 rows
. . exported "SCOTT"."T_PARTITION_RANGE":"P2"            5.046 KB       5 rows
. . exported "SCOTT"."T_PARTITION_RANGE":"P3"            5.046 KB       5 rows
. . exported "SCOTT"."T_PARTITION_RANGE":"PMAX"          5.046 KB       5 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
  /home/oracle/test.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Thu May 14 02:25:20 2020 elapsed 0 00:00:20

 

可以看出,每個區分都導出了5行。

 

這...應該是BUG吧?

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM