MOVE DATA
IMPORT 类似于应用程序,会将文件中的记录转换成INSERT语句将记录插入到数据库中,而LOAD则是直接格式化页将数据直接写到页中。
Db2 import commitcount n
Db2 import restartcount n
可以IMPORT 的文件类型DEL 有分割字符的ASCII文件 ,ASC定长记录的ASCII文件,WSF 是Lotus格式,PC/IXF
使用EXPORT时UDT的数据类型不会被EXPORT出 只能是UDT的基础数据类型被EXPORT出来。
D:test>db2 export to tbdau1.ixf of ixf lobs to d:test lobfile tbdau1.lob modif
ied by lobsinfile select * from db.tbdau1
指定EXPORT 大对象到单独文件
D:test>db2 export to emp2.ixf of ixf method n (empno,firstnme,lastname) select
empno,firstnme,lastname from employee
指定EXPORT 特定的列 METHOD N 只是在IXF 文件中指定
D:test>db2 import from emp2.ixf of ixf insert into test11(empno,firstnme,lastn
ame)
将指定的列IMPORT 到表中
使用EXPORT 必须具有SYSADM或DBADM或对表有CONTROL或者SELECT权限
>>-EXPORT TO--filename--OF--filetype---------------------------->
>--+-----------------------+--+-----------------------+--------->
| .-,--------. | | .-,--------. |
| V | | | V | |
'-LOBS TO----lob-path-+-' '-LOBFILE----filename-+-'
>--+----------------------+--+-----------------------+---------->
| .-,--------. | | .-,--------. |
| V | | | V | |
'-XML TO----xml-path-+-' '-XMLFILE----filename-+-'
>--+-------------------------------+--+---------------+--------->
| .--------------. | '-XMLSAVESCHEMA-'
| V | |
'-MODIFIED BY----filetype-mod-+-'
>--+---------------------------------+-------------------------->
| .-,-----------. |
| V | |
'-METHOD N--(----column-name-+--)-'
>--+------------------------+----------------------------------->
'-MESSAGES--message-file-'
>--+-select-statement---------------------------------------+--><
+-XQUERY--xquery-statement-------------------------------+
'-HIERARCHY--+-STARTING--sub-table-name-+--+-----------+-'
'-| traversal-order-list |-' | .-------. |
| V | |
'---WHERE-+-'
traversal-order-list
.-,--------------.
V |
|--(----sub-table-name-+--)-------------------------------------|
IMPORT. . .
>>-IMPORT FROM--filename--OF--filetype-------------------------->
>--+-------------------------+--+------------------------+------>
| .-,--------. | | .-,--------. |
| V | | | V | |
'-LOBS FROM----lob-path-+-' '-XML FROM----xml-path-+-'
>--+-------------------------------+---------------------------->
| .--------------. |
| V | |
'-MODIFIED BY----filetype-mod-+-'
>--+-------------------------------------------------------------------------------------------------------+-->
| .-,------------------------. |
| V | |
'-METHOD--+-L--(----column-start--column-end-+--)--+------------------------------------------------+-+-'
| | .-,-------------------. | |
| | V | | |
| '-NULL INDICATORS--(----null-indicator-list-+--)-' |
| .-,-----------. |
| V | |
+-N--(----column-name-+--)------------------------------------------------------------------+
| .-,---------------. |
| V | |
'-P--(----column-position-+--)--------------------------------------------------------------'
>--+------------------------------------+----------------------->
'-XMLPARSE--+-STRIP----+--WHITESPACE-'
'-PRESERVE-'
>--+--------------------------------------------------------------------------------------+-->
'-XMLVALIDATE USING--+-XDS--+-----------------------+--| Ignore and Map parameters |-+-'
| '-DEFAULT--schema-sqlid-' |
+-SCHEMA--schema-sqlid------------------------------------------+
'-SCHEMALOCATION HINTS------------------------------------------'
.-ALLOW NO ACCESS----.
>--+--------------------+--+----------------------------+------->
'-ALLOW WRITE ACCESS-' '-COMMITCOUNT--+-n---------+-'
'-AUTOMATIC-'
>--+---------------------+--+-------------+--------------------->
'-+-RESTARTCOUNT-+--n-' '-ROWCOUNT--n-'
'-SKIPCOUNT----'
>--+-----------------+--+-----------+--------------------------->
'-WARNINGCOUNT--n-' '-NOTIMEOUT-'
>--+------------------------+----------------------------------->
'-MESSAGES--message-file-'
>--+-+-INSERT---------+--INTO--+-table-name--+-------------------------+-+----------------------+-><
| +-INSERT_UPDATE--+ | | .-,-------------. | | |
| +-REPLACE--------+ | | V | | | |
| '-REPLACE_CREATE-' | '-(----insert-column-+--)-' | |
| '-| hierarchy description |---------------' |
'-CREATE--INTO--+-table-name--+-------------------------+--------------+--| tblspace-specs |-'
| | .-,-------------. | |
| | V | | |
| '-(----insert-column-+--)-' |
'-| hierarchy description |--+-AS ROOT TABLE---------+-'
'-UNDER--sub-table-name-'
Ignore and Map parameters
|--+--------------------------------+--------------------------->
| .-,------------. |
| V | |
'-IGNORE--(----schema-sqlid-+--)-'
>--+----------------------------------------------------+-------|
| .-,-----------------------------------. |
| V | |
'-MAP--(----(--schema-sqlid--,--schema-sqlid--)-+--)-'
hierarchy description
.-ALL TABLES---------.
|--+-| sub-table-list |-+--+----+------------------------------->
'-IN-'
>--HIERARCHY--+-STARTING--sub-table-name-+----------------------|
'-| traversal-order-list |-'
sub-table-list
.-,-------------------------------------------.
V |
|--(----sub-table-name--+-------------------------+-+--)--------|
| .-,-------------. |
| V | |
'-(----insert-column-+--)-'
traversal-order-list
.-,--------------.
V |
|--(----sub-table-name-+--)-------------------------------------|
tblspace-specs
|--+----------------------------------------------------------------------------------+--|
'-IN--tablespace-name--+---------------------------+--+--------------------------+-'
'-INDEX IN--tablespace-name-' '-LONG IN--tablespace-name-'
D:test>db2 import from tbdau1.ixf of ixf lobs from d:test modified by lobsinfi
le allow write access commitcount 100 messages tbdau1.msg insert into tbdau1
读取行数 = 2903
跳过行数 = 0
插入行数 = 2903
更新行数 = 0
拒绝行数 = 0
落实行数 = 2903
指定ALLOW WRITE ACCESS 这个在表上放IX锁,如果什么也不指定默认放X缩
METHOD L(1 3,4 6) 指定定长记录
METHOD N
D:test>db2 import from emp2.ixf of ixf insert into test11 (empno,firstnme,lastn
ame) 指定要IMPORT的记录的名字
METHOD P 指定IMPORT 文件的要IMPORT数据的位置
D:test>db2 import from emp2.ixf of ixf method p (1,2,3) insert into test11(empn
o,firstnme,lastname)
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8188536/viewspace-1028061/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8188536/viewspace-1028061/