12
© Copyright IBM Corporation 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3 Command Line Processor (CLP) and GUI usage

Command Line Processor (CLP) and GUI usage

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3

Command Line Processor (CLP) and GUI usage

Page 2: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

CLP Command Line Processor

Page 3: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

CLP syntax

phrase

message

sql-state

class-code

db2

option-flag db2-command

sql-statement

?

Page 4: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

Online reference

Online Command Reference

db2 ?db2 ? command stringdb2 ? SQLnnnn (nnnn = 4 or 5 digit SQLCODE)db2 ? nnnnn (nnnnn = 5 digit SQLSTATE)

Online Reference Manuals

Page 5: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

Using the CLP

db2=> connect to musicdbdb2=> select * from syscat.tables

(double quotes may be required)

db2 connect to musicdbdb2 "select * from syscat.tables" more

Interactive mode

db2

Non-interactive mode

Page 6: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

QUIT/TERMINATE/CONNECT RESET differences

CLPCOMMAND

connect reset

Terminate CLPBack-end Process

No

Disconnectdatabase Connection

quit No No

terminate Yes Yes

Yes ifCONNECT=1

(RUOW)

Page 7: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

CLP command options

db2 list command options

Page 8: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

Modify CLP options

3

1

2

3

4

Temporary for Command

Temporary for Interactive CLP Session

Temporary for non-interactive CLP Session

Every session

db2 -r options.rep list command optionsdb2 -svtf create.tab3db2 +c "update tab3 set salary=salary + 100"

db2=>update command options using c off a on

export DB2OPTIONS="-svt" (UNIX)set DB2OPTIONS="-svt" (Windows)db2 -f create.tab3

put point in UNIX db2profileor System Program Group in Windows

Page 9: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

Input file — no operating system commands

Edit create.tab

-- comment: db2 -svtf create.tab

connect to sample;

create table tab3 (name varchar(20) not null, phone char(40), salary dec(7,2));

select * from tab3;

commit work;

connect reset;

db2 -svtf create.tab

Page 10: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

What is an instance?

DB2 PRODUCT

DBM CFG

DB_1

DB CFG

Catalog LOG

DB_2

DB CFG

Catalog LOG

DBM CFG

DB_3

DB CFG

Catalog LOG

Instance_1 Instance_2

Page 11: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

Create database overview

Databases are created within a Database Manager instance

Table spaces are a logical layer created within database

Tables are created within table spaces

Table 1 Table 4Table 2 Table 3 Table 1 Table 2

Database Manager Instance

database1

Tablespace ATablespace B

database2

Tablespace A

Page 12: Command Line Processor (CLP) and GUI usage

© Copyright IBM Corporation 2007

System Catalog tables and views

SYSCAT

SYSSTAT

views

SYSIBM.SYSCOLUMNSSYSIBM.SYSTABLES

......