db2匯出資料庫定義及遷移資料

long_small發表於2022-04-27

db2匯出全庫定義

① db2look -d sample(庫名稱) -a -e -l -x -o ddl20210420.out

db2look -d sample(庫名稱) -a -e  -x -f -o ddl20210420.out (匯出表,索引,序列等物件)

③   db2look -d sample -createdb -printdbcfg -l -o ddl0423.out(資料庫建庫語句,包含buffpool,tablesapces,引數)

   -- db2look -d sample(庫名稱) -a -ct -x -o   ddl20210420.out(匯出表,索引,序列等物件)


匯出資料

[db2inst1@long-ibm1 ~]$ db2 "select * from db2inst1.org"


DEPTNUMB DEPTNAME       MANAGER DIVISION   LOCATION     

-------- -------------- ------- ---------- -------------

      10 Head Office        160 Corporate  New York     

      15 New England         50 Eastern    Boston       

      20 Mid Atlantic        10 Eastern    Washington   

      38 South Atlantic      30 Eastern    Atlanta      

      42 Great Lakes        100 Midwest    Chicago      

      51 Plains             140 Midwest    Dallas       

      66 Pacific            270 Western    San Francisco

      84 Mountain           290 Western    Denver       


  8 record(s) selected.


[db2inst1@long-ibm1 ~]$ db2 "export to db2inst1.org of ixf select * from db2inst1.org"


刪除資料

 db2 "delete from  db2inst1.org"


匯入資料

[db2inst1@long-ibm1 ~]$ db2 "export to db2inst1.org of ixf select * from db2inst1.org"


db2 "select * from db2inst1.org"

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

相關文章