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:
- db2start
- db2 list db directory
- db2 list applications show detail
- db2 “create db testdb using codeset utf-8 territory cn”
- db2 drop db testdb
- db2 backup db testdb to c:
- db2 restore db testdb from c:
- db2 get db cfg for testdb
- db2 connect to testdb
- db2 connect to testdb user dbuser using dbpassword
- db2 connect reset
- db2 connect
- db2 get snapshot for dynamic sql on testdb
- db2 set schema TEST
- db2 “list tables for all” | grep -i “test”
- db2 “list tables for schema bill”
- db2 “create table test (id integer primary key not null, name varchar(64), birthdate date, updatedttm timestamp, updateuser varchar(32))”
- db2 “create table test (id integer not null, name varchar(64), birthdate date, updatedttm timestamp, updateuser varchar(32), primary key(id))”
- db2 “alter table test add column versionstamp smallint default 1”
- db2 “alter table test alter name set data type varchar(128)”
- db2 “create alias BILL.test for TEST.test”
- db2 “grant select,insert,update,delete on BILL.test to user dbuser”
- db2 “drop alias BILL.test”
- db2 “drop table test”
- db2 “insert into test(id, name, birthdate, updatedttm, updateuser) values (1, ‘Bill Yang’,’1983-03-27′,current timestamp, ‘test’)”
- db2 “update test set birthdate=’1983-3-28′ where id=1”
- db2 “select * from test fetch first 5 rows only”
- db2 “select substr(imagedesc, 1, 50) from test”
- db2 “select current date – 35 days from sysibm.sysdummy1”
- db2 “select date(‘2018-09-17’) from sysibm.sysdummy1”