[20151126]IMPDP TRANSFORM参数.TXT

[20151126]IMPDP TRANSFORM参数.TXT

--最近要建立一个测试库,原来生产系统的一些表在定义时
STORAGE    (
            INITIAL          8G
            ....
           )
NOPARALLEL;

--实际我不需要建立这个大的INITIAL表,而且可能许多还是空的。有些我可能仅仅导入少量数据,这样要浪费大量磁盘空间,并且测试
--机器磁盘空间也不足。不能这样导入。

--另外一个问题有一些表我设置PCTFREE很大(缺省10),主要问题是避免行迁移。如果这样导入也会导致磁盘空间浪费。

--这导致我开始想通过先建立空表,然后导入的想法,我仔细阅读参数TABLE_EXISTS_ACTION,参考链接
--http://blog.itpub.net/267265/viewspace-1846224/

--晚上我仔细看一些文档,发现oracle 11G还支持参数TRANSFORM,通过这个参数可以屏蔽原来的参数,还是通过例子来说明:

1.建立测试环境:

SCOTT@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--建立如下表:
CREATE TABLE SCOTT.EMPX
(
  EMPNO     NUMBER(4),
  ENAME     VARCHAR2(10 BYTE),
  JOB       VARCHAR2(9 BYTE),
  MGR       NUMBER(4),
  HIREDATE  DATE,
  SAL       NUMBER(7,2),
  COMM      NUMBER(7,2),
  DEPTNO    NUMBER(2)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    50
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          50M
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;

SCOTT@book> insert into empx select * from emp ;
14 rows created.

SCOTT@book> commit ;
Commit complete.

--建立表empx,INITIAL=50M,PCTFREE=50.

SCOTT@book> select segment_name,bytes,blocks,INITIAL_EXTENT,NEXT_EXTENT from dba_segments where owner=user and segment_name='EMPX';
SEGMENT_NAME              BYTES     BLOCKS INITIAL_EXTENT NEXT_EXTENT
-------------------- ---------- ---------- -------------- -----------
EMPX                   52428800       6400       52428800     1048576

SCOTT@book> column PARTITION_NAME noprint
SCOTT@book> select * from dba_extents where owner=user and segment_name='EMPX';
OWNER  SEGMENT_NAME         SEGMENT_TYPE       TABLESPACE_NAME  EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
------ -------------------- ------------------ -------------------------- ---------- ---------- ---------- ---------- ------------
SCOTT  EMPX                 TABLE              USERS                    0          4       1280    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    1          4       2304    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    2          4       3328    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    3          4       4352    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    4          4       5376    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    5          4       6400    8388608       1024            4
SCOTT  EMPX                 TABLE              USERS                    6          4       7424    1048576        128            4
SCOTT  EMPX                 TABLE              USERS                    7          4       7552    1048576        128            4
8 rows selected.

--可以看到分配6个8M的段,2个1M的段。这样占用很大的磁盘空间。

2.导出:
$ expdp scott/book  dumpfile=empx78.dmp logfile=empx78.log tables=scott.empx
Export: Release 11.2.0.4.0 - Production on Thu Nov 26 09:47:13 2015
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 "SCOTT"."SYS_EXPORT_TABLE_01":  scott/a******* dumpfile=empx78.dmp logfile=empx78.log tables=scott.empx
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 50 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."EMPX"                              8.562 KB      14 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
  /u01/app/oracle/admin/book/dpdump/empx78.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Thu Nov 26 09:47:28 2015 elapsed 0 00:00:11

3.如果按照原来导入,占用50M太浪费:

Usage: TRANSFORM = transform_name:value[:object_type]
These are the applicable transform_names

    SEGMENT_ATTRIBUTES: by default value is y which will copy the objects as it is in the export dump with all segment
    attributes. If you specify the value as n the import job will omit the segment_attributes in the dump file and it
    will use the tablespace/user default values.

    STORAGE: by default the value for this parameter is y which will include all storage clauses during the import job.
    If you specify the parameter value as n then it will omit the storage clause in the dump file and it will follow the
    default values in the tablespace.

    PCTSPACE: it is the percent multiplier for the extent allocations and size of the datafiles during the import.

    OID: object id (OID) mainly used for the TYPE objects. Each and every type is identified by OID which will be
    unique. If you create a type without specifying the OID the RDBMS itself will create and assign unique OID to the
    new TYPE object. See below examples for more details.

$ impdp scott/book dumpfile=empx78.dmp logfile=empx78x.log remap_table=scott.empx:empy full=y transform=SEGMENT_ATTRIBUTES:n:table,STORAGE:N:table
Import: Release 11.2.0.4.0 - Production on Thu Nov 26 09:53:46 2015
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
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/a***** dumpfile=empx78.dmp logfile=empx78x.log remap_table=scott.empx:empy full=y transform=SEGMENT_ATTRIBUTES:n:table,STORAGE:N:table
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."EMPY"                              8.562 KB      14 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at Thu Nov 26 09:53:51 2015 elapsed 0 00:00:03

SCOTT@book> @ &r/ddl scott.empy
C100
---------------------------------------------------------------------------------
  CREATE TABLE "SCOTT"."EMPY"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10),
        "JOB" VARCHAR2(9),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;

--注意看INITIAL=64k,PCTFREE=10.

SCOTT@book> select * from dba_extents where owner=user and segment_name='EMPY';
OWNER  SEGMENT_NAME         SEGMENT_TYPE       TABLESPACE_NAME                 EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
------ -------------------- ------------------ ------------------------------ ---------- ---------- ---------- ---------- ---------- ------------
SCOTT  EMPY                 TABLE              USERS                                   0          4        744      65536          8            4

--这样就符合我的需要了。我还可以先导入表定义,这样再通过其它的方式插入数据。使用参数CONTENT=METADATA_ONLY。
--例子:

$ impdp scott/book dumpfile=empx78.dmp logfile=empx78x.log remap_table=scott.empx:empz full=y transform=SEGMENT_ATTRIBUTES:n:table,STORAGE:N:table CONTENT=METADATA_ONLY
Import: Release 11.2.0.4.0 - Production on Thu Nov 26 09:58:50 2015
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
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/a******* dumpfile=empx78.dmp logfile=empx78x.log remap_table=scott.empx:empz full=y transform=SEGMENT_ATTRIBUTES:n:table,STORAGE:N:table CONTENT=METADATA_ONLY
Processing object type TABLE_EXPORT/TABLE/TABLE
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at Thu Nov 26 09:58:54 2015 elapsed 0 00:00:02

SCOTT@book> select * from dba_extents where owner=user and segment_name='EMPZ';
no rows selected

--如果不指定后面的参数:table,改成如下SEGMENT_ATTRIBUTES:n, 对其它object_type也有效。

时间: 2024-09-20 14:56:02

[20151126]IMPDP TRANSFORM参数.TXT的相关文章

[20150126]datadump的非文档参数.txt

[20150126]datadump的非文档参数.txt --总结一下expdp/impdp的非文档参数: 1. METRICS METRICS=Y ,记录执行详细的执行时间.例子: $ expdp scott/btbtms DIRECTORY=DATA_PUMP_DIR  DUMPFILE=emp012601.dmp LOGFILE=emp012601.log tables=emp metrics=y Export: Release 11.2.0.3.0 - Production on Mon

[20140820]显示存储过程的参数.txt

[20140820]显示存储过程的参数.txt --上午写一个显示存储过程参数的例子,便于自己以后使用. --主要是desc显示的信息太大,查看不是很方便. SCOTT@test> desc dbms_stats PROCEDURE ALTER_DATABASE_TAB_MONITORING Argument Name                  Type                    In/Out Default? ------------------------------ -

[20171206]SQLTUNE_CATEGORY参数.txt

[20171206]SQLTUNE_CATEGORY参数.txt --//今天提示别人使用sql profile优化语句,使用DBMS_SQLTUNE.import_sql_profile的引入替换功能.一般我的测试 --//category参数是'',也就是NULL.如果指定如何优化确定优化有效呢? --//链接:http://www.itpub.net/thread-2094823-1-1.html --//实际上就是修改参数SQLTUNE_CATEGORY. --//https://doc

[20170313]11G use_large_pages参数.txt

[20170313]11G use_large_pages参数.txt --11G 增加参数use_large_pages,可以灵活使用hugepages. 1.环境: SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- --------------------------------------------

[20170209]理解pre_page_sga参数.txt

[20170209]理解pre_page_sga参数.txt --昨天测试pre_page_sga=true的情况: http://blog.itpub.net/267265/viewspace-2133198/ --//再次看看官方的定义: http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams201.htm#REFRN10174 PRE_PAGE_SGA determines whether Oracle reads

[20161123]failover与会话参数.txt

[20161123]failover与会话参数.txt --前几天itpub上有人问的问题,链接http://www.itpub.net/thread-2071933-1-1.html,开始我以为是会话没有退出. --实际上对方已经重启过数据库,不过后来我估计对方打开登录审计,从结果上猜测是正确的,不过我的问题是我想了解 --会话在支持failover时,重新连接上时会话参数是否还是原来的,还有审计是否还有效(在已经关闭相关审计的情况下). --测试是最好的证明,还是通过例子来说明问题. 1.环

[20171211]检查dg配置参数.txt

[20171211]检查dg配置参数.txt --//写一个脚本,用来检查dg配置参数. col name    for a30 col value   for a120 col ses_mod for a10 col sys_mod for a10 col ins_mod for a10 col type format 99999 SELECT p.name,        p.type,        p.value,        p.isses_modifiable      as SE

[20130105]expdp的include和exclude参数.txt

[20130105]expdp的include和exclude参数.txt http://www.itpub.net/thread-1754104-1-1.html 如果include,exclude参数很长,可以通过建立一张表来实现.自己做一些测试(注直接在命令行输入语法加入斜线,很烦!): 1.使用include参数:$ cat par.txtDIRECTORY=DATA_PUMP_DIRDUMPFILE=scott.dmpINCLUDE=TABLE:"IN (Select table_na

[20120918]exp要注意的问题CONSISTENT参数.txt

[20120918]exp要注意的问题CONSISTENT参数.txt     前几天开发要导出一个schema做测试,因为新程序改动太大,要求导出一份该schema下的全部数据,开发导入后出现 一些错误,反馈日志log后,才发现是主外键的问题,原来我忘记在导出时加入参数CONSISTENT=y. 缺省这个参数是N. 今天做一个测试看看差别在哪里: exp前先刷新共享池. alter system flush shared_pool; host exp sh/xxxxxx file=aaa.dm