User Tools

Site Tools


database:db2

Autoincrement

  CREATE TABLE X
  (
     myid DECIMAL(10) GENERATED
          BY DEFAULT AS IDENTITY
             (START WITH 0, INCREMENT BY 1, NO CACHE),
     ...
  );

TOP ROWS

Mit fetch first N rows only kann man native dem DB2 sagen, dass nur die ersten N Zeilen interessieren.

DSNs eintragen

catalog tcpip node <mynodename> remote db001.noc.goebl.com server 50190
catalog db <mydbname> at node <mynodename>

DSNs anzeigen

list db directory
list node directory

Timestamp strings

A string representation of a timestamp is a string that starts with a digit and has a length of at least 16 characters. The complete string representation of a timestamp has the form yyyy-mm-dd-hh.mm.ss.nnnnnn. Trailing blanks may be included. Leading zeros may be omitted from the month, day, and hour part of the timestamp, and microseconds may be truncated or entirely omitted. If any trailing zero digits are omitted in the microseconds portion, an implicit specification of 0 is assumed for the missing digits. Thus, 1991-3-2-8.30.00 is equivalent to 1991-03-02-08.30.00.000000.

db2 command line

db2
  -c ==> automatic commit
  -t ==> semicolon as separator
  -s ==> stop after error
  -f sqlfile
  -l logfile
  -z outputfile

DB2 monitoren und optimieren

db2 => connect to dbname user username using password
db2 => update monitor switches using statement on
db2 => create event monitor rkmon for statements write to table
db2 => set event monitor rkmon state=1 (schaltet den Monitor ein)

Anwendung bedienen, die SQL-Abfragen auslöst.

db2 => set event monitor rkmon state=0 (schaltet den Monitor aus)

Auswertungsbeispiel:

db2 => select START_TIME,FETCH_COUNT,ROWS_READ,STMT_TEXT from STMT_RKMON order by rows_read desc;

siehe auch: http://www-128.ibm.com/developerworks/db2/library/techarticle/0303kolluru/0303kolluru.html

database/db2.txt · Last modified: 2010/08/10 20:25 by hgoebl