db2 load命令学习

db2 load命令学习


获得LOAD权限:数据库级别权限,可以授予组和用户。在填充具有大量数据的表时可以使用LOAD命令。根据执行的LOAD类型不同,可能还需要其他特权

    LOAD权限的内容:

        db2 quiesce tablespaces for table

        db2 list tablespaces

        db2 runstats(任何表)

        db2 load insert(必须对表有插入特权)

        db2 load restart/terminate after load insert(必须对表具有插入特权)

        db2 load replace(必须对表有插入/删除特权)

        db2 load restart/terminate after load replace(同上)

实际执行load命令的用户不是登陆进去应用的用户, 应该是administrator权限的db2inst1,所以出现权限不够的问题

 

load过程中,表空间的状态 http://www.daima.com.cn/Info/70/Info26799/

db2一些有用资料 http://www.daima.com.cn/Info/Info70To1/

 

DB2 LOAD 操作可以分成四个阶段。这四个阶段是以连续方式发生的:

 

装入阶段 - 本阶段中,将外部文件中的数据装入表中。对索引进行收集和排序。本阶段中的一件重要事情就是对装入操作进行保存点检查。如果装入失败,就需要该保存点,并且需要执行重载。保存点允许执行这一可重载的功能。本阶段中,无效记录将写入一个消息文件中。

构建阶段 - 本阶段中,将构建索引。如果在该阶段中发生故障,装入操作的重新启动将导致构建阶段从头开始。在该阶段期间,将生成消息。

删除阶段 - 本阶段中,将注意是否违反惟一性和主键约束。违反的行将写入异常表。如果在该阶段中发生故障,装入操作的重新启动将导致删除阶段从头开始。在该阶段期间,将生成消息。

索引复制阶段 - 本阶段中,要将索引从系统临时表空间移至目标表空间。只有在执行装入时为索引的创建指定了系统临时表空间,这一阶段才会发生。在该阶段中,将生成消息。

DB2 LOAD 允许追加或替换数据。在执行装入操作时,将创建一个中间表,以帮助进行装入。可以用 CURSOR 文件类型代替。 同时,还可以选择许多选项,例如:

 

WARNINGCOUNT - 指定何时停止装入。当达到 n 条警告时,装入操作将停止。

CPU_PARALLELISM - 指定 CPU 的并行度。其默认值是一个由 DB2 确定的较明智的值。

DISK_PARALLELISM - 指定磁盘的并行度。该值确定要派生的线程数目。其默认值是一个由 DB2 确定的较明智的值。

DATA BUFFER - 指定要使用的 4K 页面的数目。

TEMPFILES PATH - 指定在装入期间创建中间表时要使用的路径。

FOR EXCETION - 指定将所有有问题的行写入其中的表。

DUMPFILE - 指定转储拒绝行错误的文件名。

NOROWWARNING - 指定对于拒绝行不写入警告。

 

DB2 LOAD 提供了一些性能调优功能,因为在装入操作期间,可以为创建的页面指定总空间。

 

PAGEFREESPACE - 每个数据页留下的空闲百分比。通常,让该值为 DB2 所确定的默认值。

INDEXFREESPACE - 每个索引页留下的空闲百分比。通常,让该值为 DB2 所确定的默认值。

TOTALFREESPACE - 追加为空闲空间的表大小百分比。

The SET INTEGRITY command must be used to take the table out of CHECK PENDING.

 

Load选项:

 

选项                           适应命令               表状态

 

ALLOW NO ACCESS--LOAD REPLACE--LOAD IN PROGRESS

 

ALLOW READ ACCESS--LOAD TERMINATE or LOAD RESTART  LOAD IN PROGRESS and READ ACCESS.     可以使用USE tablespace-name(索引的拷贝)Only system temporary table spaces can be used with this option.This option is ignored if the user does not specify INDEXING MODE REBUILD or INDEXING MODE AUTOSELECT. This option will also be ignored if INDEXING MODE

AUTOSELECT is chosen and load chooses to incrementally update the index.Without this option the shadow index is built in the same table space as the original. Since both the original index and shadow index by default reside in the same table space.

 

 

 

CHECK PENDING CASCADE    默认为DEFERRED

 

     IMMEDIATE :Indicates that the check pending state (read or no access mode) for foreign

 

                       key constraints is immediately extended to all descendent foreign key tables.

 

     DEFERRED:Indicates that only the loaded table will be placed in the check pending state

 

                    (read or no access mode).

 

 

 

CLIENT

 

Notes:

1. The DUMPFILE and LOBSINFILE modifiers refer to files on the

server even when the CLIENT keyword is specified.

2. Code page conversion is not performed during a remote load

operation. If the code page of the data is different from that of the

server, the data code page should be specified using the

CODEPAGE modifier.

 

 

 

COPY NO    

 

Copy no, will also put the table space state  into the Load in Progress table space state.

 

However, it is possible to access the data in any table by using the SELECTstatement.

 

 

COPY YES

 

    USE TSM

 

    OPEN num-sess SESSIONS

 

    TO device/directory

 

    LOAD lib-name

 

 

 

CPU_PARALLELISM n

 

Specifies the number of processes or threads that the load utility will  spawn for parsing, converting, and formatting records when building

table objects. This parameter is designed to exploit intra-partition

parallelism. It is particularly useful when loading presorted data,

because record order in the source data is preserved. If the value of

this parameter is zero, or has not been specified, the load utility uses

an intelligent default value (usually based on the number of CPUs

available) at run time.

Notes:

1. If this parameter is used with tables containing either LOB or

LONG VARCHAR fields, its value becomes one, regardless of the

number of system CPUs or the value specified by the user.

2. Specifying a small value for the SAVECOUNT parameter causes

the loader to perform many more I/O operations to flush both

data and table metadata. When CPU_PARALLELISM is greater

than one, the flushing operations are asynchronous, permitting the

loader to exploit the CPU. When CPU_PARALLELISM is set to

one, the loader waits on I/O during consistency points. A load

operation with CPU_PARALLELISM set to two, and SAVECOUNT

set to 10 000, completes faster than the same operation with

CPU_PARALLELISM set to one, even though there is only one

CPU.

 

 

 

 DATA BUFFER buffer-size

 

4kb为一单位。如果没有指定,那么程序在运行的时候根据需要自动分配一个合适的值。这段内存在utility heap中分配,因此可以改变util_heap_sz的大小来改变能分配给 DATA BUFFER的大小。

 

 

 

DATALINK SPECIFICATION  ????

 

 

 

DISK_PARALLELISM n  磁盘并行度。Specifies the number of processes or threads that the load utility will  spawn for writing data to the table space containers.

 

 

 

DL_LINKTYPE

 

 

 

DL_URL_DEFAULT_PREFIX prefix


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值