db2 load 自增測試

flywiththewind發表於2016-12-27
[db2inst1@db2 ~]$ db2 "create table admin.xpf (id int generated always as identity (start with 1 increment by 1 no cache nocycle),name varchar(20),address varchar(20),phonenum char(11))"
DB20000I  The SQL command completed successfully.
[db2inst1@db2 ~]$ db2 "insert into admin.xpf(name,address,phonenum) values ('xpf','hbyx','18618196076')"
DB20000I  The SQL command completed successfully.
[db2inst1@db2 ~]$ db2 set current schema admin
DB20000I  The SQL command completed successfully.
[db2inst1@db2 ~]$ db2 "select * from xpf"


ID          NAME                 ADDRESS              PHONENUM   
----------- -------------------- -------------------- -----------
          1 xpf                  hbyx                 18618196076


  1 record(s) selected.


[db2inst1@db2 ~]$ db2 "insert into xpf values(9,'linda','usa','13131231234')"
DB21034E  The command was processed as an SQL statement because it was not a 
valid Command Line Processor command.  During SQL processing it returned:
SQL0798N  A value cannot be specified for column "ID" which is defined as 
GENERATED ALWAYS.  SQLSTATE=428C9
[db2inst1@db2 ~]$ db2 "insert into xpf(name,address,phonenum) values('linda','usa','13131231234')"
DB20000I  The SQL command completed successfully.
[db2inst1@db2 ~]$ db2 "select * from xpf"


ID          NAME                 ADDRESS              PHONENUM   
----------- -------------------- -------------------- -----------
          1 xpf                  hbyx                 18618196076
          2 linda                usa                  13131231234


  2 record(s) selected.

[db2inst1@db2 ~]$ cat 1.del 
10,'james','lakes','110'
90,'katte','aus','119'


[db2inst1@db2 ~]$ db2 "load from 1.del of del modified by identityoverride insert into admin.xpf"
SQL3551W  The table contains at least one GENERATED ALWAYS column that the 
utility will override.


SQL3109N  The utility is beginning to load data from file 
"/db2home/db2inst1/1.del".


SQL3500W  The utility is beginning the "LOAD" phase at time "12/27/2016 
22:32:09.928256".


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 "12/27/2016 
22:32:10.052981".




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


[db2inst1@db2 ~]$ db2 "select * from xpf"


ID          NAME                 ADDRESS              PHONENUM   
----------- -------------------- -------------------- -----------
          1 xpf                  hbyx                 18618196076
          2 linda                usa                  13131231234
         10 'james'              'lakes'              '110'      
         90 'katte'              'aus'                '119'      


  4 record(s) selected.


[db2inst1@db2 ~]$ db2 "load from 1.del of del modified by identitymissing insert into admin.xpf"
SQL3109N  The utility is beginning to load data from file 
"/db2home/db2inst1/1.del".


SQL3500W  The utility is beginning the "LOAD" phase at time "12/27/2016 
22:32:27.512231".


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 "12/27/2016 
22:32:27.755237".




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


[db2inst1@db2 ~]$ db2 "select * from xpf"


ID          NAME                 ADDRESS              PHONENUM   
----------- -------------------- -------------------- -----------
          1 xpf                  hbyx                 18618196076
          2 linda                usa                  13131231234
         10 'james'              'lakes'              '110'      
         90 'katte'              'aus'                '119'      
          3 10                   'james'              'lakes'    
          4 90                   'katte'              'aus'      


  6 record(s) selected.


[db2inst1@db2 ~]$ db2 "load from 1.del of del modified by identityignore insert into admin.xpf"
SQL3109N  The utility is beginning to load data from file 
"/db2home/db2inst1/1.del".


SQL3500W  The utility is beginning the "LOAD" phase at time "12/27/2016 
22:33:47.293690".


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 "12/27/2016 
22:33:47.399742".




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


[db2inst1@db2 ~]$ db2 "select * from xpf"


ID          NAME                 ADDRESS              PHONENUM   
----------- -------------------- -------------------- -----------
          1 xpf                  hbyx                 18618196076
          2 linda                usa                  13131231234
         10 'james'              'lakes'              '110'      
         90 'katte'              'aus'                '119'      
          3 10                   'james'              'lakes'    
          4 90                   'katte'              'aus'      
          5 'james'              'lakes'              '110'      
          6 'katte'              'aus'                '119'      


  8 record(s) selected.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26224914/viewspace-2131454/,如需轉載,請註明出處,否則將追究法律責任。

相關文章