DB2 frequently used commands (To be continued)

Note: 
Assuming that already in the db2clp environment. And the following examples is base on the following environment and parameters (should be same with *nix like commands environment):
Environment: Windows XP + PuttyCyg + DB2/NT 9.5.4 + Cygwin
Database name: testdb
Username/Password: dbuser/dbpassword
Schema: BILL
List of the most frequently used commands during my working:
  1. db2start
  2. db2 list db directory
  3. db2 list applications show detail
  4. db2 “create db testdb using codeset utf-8 territory cn”
  5. db2 drop db testdb
  6. db2 backup db testdb to c:
  7. db2 restore db testdb from c:
  8. db2 get db cfg for testdb
  9. db2 connect to testdb
  10. db2 connect to testdb user dbuser using dbpassword
  11. db2 connect reset
  12. db2 connect
  13. db2 get snapshot for dynamic sql on testdb
  14. db2 set schema TEST
  15. db2 “list tables for all” | grep -i “test”
  16. db2 “list tables for schema bill”
  17. db2 “create table test (id integer primary key not null, name varchar(64), birthdate date, updatedttm timestamp, updateuser varchar(32))”
  18. db2 “create table test (id integer not null, name varchar(64), birthdate date, updatedttm timestamp, updateuser varchar(32), primary key(id))”
  19. db2 “alter table test add column versionstamp smallint default 1”
  20. db2 “alter table test alter name set data type varchar(128)”
  21. db2 “create alias BILL.test for TEST.test”
  22. db2 “grant select,insert,update,delete on BILL.test to user dbuser”
  23. db2 “drop alias BILL.test”
  24. db2 “drop table test”
  25. db2 “insert into test(id, name, birthdate, updatedttm, updateuser) values (1, ‘Bill Yang’,’1983-03-27′,current timestamp, ‘test’)”
  26. db2 “update test set birthdate=’1983-3-28′ where id=1”
  27. db2 “select * from test fetch first 5 rows only”
  28. db2 “select substr(imagedesc, 1, 50) from test”
  29. db2 “select current date – 35 days from sysibm.sysdummy1”
  30. db2 “select date(‘2018-09-17’) from sysibm.sysdummy1”

Leave a Reply

Your email address will not be published. Required fields are marked *