关于db2 load命令多加一列参数值该怎么写?
发布网友
发布时间:2022-05-02 00:26
我来回答
共1个回答
热心网友
时间:2022-04-14 04:40
(一)如下思路供参考:
1)改第11列的定义 添加默认值
db2 alter table <表名> alter column col11 set default <默认值>
2)执行导入语句
db2 load from <文件名> of <文件类型> insert into <表名>(col1,col2,col3...col10) nonrecoverable
3)如果只需要做一次,之后再修改11列定义,删除默认值
db2 alter table <表名> alter column col11 drop default
(二)如下是测试例子:
C:\cap_log>
C:\cap_log>
C:\cap_log>db2 select * from tab1
A B
----------- -
1 a
2 a
1 a
2 a
1 b
2 b
6 record(s) selected.
C:\cap_log>db2 alter table tab1 alter column b set default 'W'
DB20000I The SQL command completed successfully.
C:\cap_log>more 1.del
1
2
C:\cap_log>db2 load from 1.del of del insert into tab1(a) nonrecoverable
SQL3109N The utility is beginning to load data from file "C:\cap_log\1.del".
SQL3500W The utility is beginning the "LOAD" phase at time "2014-10-01
11:45:28.077839".
SQL3519W Begin Load Consistency Point. Input record count = "0".
SQL3520W Load Consistency Point was successful.
SQL3110N The utility has completed processing. "2" rows were read from the
input file.
SQL3519W Begin Load Consistency Point. Input record count = "2".
SQL3520W Load Consistency Point was successful.
SQL3515W The utility has finished the "LOAD" phase at time "2014-10-01
11:45:28.153020".
Number of rows read = 2
Number of rows skipped = 0
Number of rows loaded = 2
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 2
C:\cap_log>db2 select * from tab1
A B
----------- -
1 a
2 a
1 a
2 a
1 b
2 b
1 W
2 W
8 record(s) selected.
C:\cap_log>db2 alter table tab1 alter column b drop default
DB20000I The SQL command completed successfully.
C:\cap_log>