导出命令
问一下db2把一个库里的个别表的数据导出来这个语句具体怎么写?
[解决办法]
del 是DB2一种数据文件的格式
这个导出命令的意思是按照这个格式导出
[解决办法]
db2 "export to textname.txt of del select * from tablename"
export to textname.txt --导出到文件textname.txt,可以包含路径入 export to /home/user/a.txt
of del --文件类型
select * from tablename --要导出结果的sql语句
[解决办法]
db2 export to awards.ixf of ixf messages msgs.txt select * from staff
where dept = 20
The following example shows how to export LOBs to a DEL file:
db2 export to myfile.del of del lobs to mylobs/
lobfile lobs1, lobs2 modified by lobsinfile
select * from emp_photo
The following example shows how to export LOBs to a DEL file, specifying a second directory for files that might not fit into the first directory:
db2 export to myfile.del of del
lobs to /db2exp1/, /db2exp2/ modified by lobsinfile
select * from emp_photo
The following example shows how to export data to a DEL file, using a single quotation mark as the string delimiter, a semicolon as the column delimiter, and a comma as the decimal point. The same convention should be used when importing data back into the database:
db2 export to myfile.del of del
modified by chardel'' coldel; decpt,
select * from staff
db2 import导入过程
db2 ? import
IMPORT FROM filename OF {IXF | ASC | DEL | WSF}
[LOBS FROM lob-path [ {,lob-path} ... ] ] [MODIFIED BY filetype-mod ...]
[METHOD {L ( col-start col-end [ {,col-start col-end} ... ] )
[NULL INDICATORS (col-position [ {,col-position} ... ] )] |
N ( col-name [ {,col-name} ... ] ) |
P ( col-position [ {,col-position} ... ] )}]
[ALLOW {NO | WRITE} ACCESS]
[COMMITCOUNT {n | AUTOMATIC}] [{RESTARTCOUNT | SKIPCOUNT} n]
[ROWCOUNT n] [WARNINGCOUNT n] [NOTIMEOUT] [MESSAGES message-file]
{{INSERT | INSERT_UPDATE | REPLACE | REPLACE_CREATE}
INTO {table-name [( insert-column , ... )] | hierarchy-description}
| CREATE INTO {table-name [( insert-column , ... )] |
hierarchy-description {AS ROOT TABLE | UNDER sub-table-name}
[IN tablespace-name [INDEX IN tablespace-name] [LONG IN tablespace-name]]}
[datalink-specification]
filetype-mod:
COMPOUND=x、INDEXSCHEMA=schema、FORCEIN、INDEXIXF、IMPLIEDDECIMAL、
NOCHECKLENGTHS、NOEOFCHAR、NULLINDCHAR、RECLEN=x、STRIPTBLANKS、
STRIPTNULLS、NO_TYPE_ID、NODOUBLEDEL、LOBSINFILE、USEDEFAULTS、
CHARDELx、COLDELx、DLDELx、DECPLUSBLANK、DECPTx、DATESISO、
DELPRIORITYCHAR、IDENTITYMISSING、IDENTITYIGNORE、
GENERATEDMISSING、GENERATEDIGNORE、DATEFORMAT=x、TIMEFORMAT=x、
TIMESTAMPFORMAT=x、KEEPBLANKS、CODEPAGE=x、NOROWWARNINGS、
NOCHARDEL 和 USEGRAPHICCODEPAGE
hierarchy-description:
{ALL TABLES | (sub-table-name [(insert-column, ...)], ...)} [IN]
HIERARCHY {STARTING sub-table-name | (sub-table-name, ...)}
datalink-specification:
([DL_LINKTYPE URL][{DL_URL_REPLACE_PREFIX prefix |
DL_URL_DEFAULT_PREFIX prefix}] [DL_URL_SUFFIX suffix], ...)
1. 增加数据
Import from aaa.del of del messages msg.out insert into product
Import from aaa.del of del messages msgout insert into product(price,prod_no,description)
2. 更新已经存在的数据及加入新数据
Import from aaa.del of del messages msg.out replace into product
3. 替换数据
Import from aaa.del of del messages msg.out replace_create into product
4. 创建表
Import from aaa.ixf of ixf messages msg.out replace_create into product
5. commitcount与restartcount选项
import from myfile.ixf of ixf commitcount 500 messages msg.out insert into newtable
import from myfile.ixf of ixf commitcount 50 restartcount 2000 messages msg.out insert into newtable
6. 导入大对象