db2cmd 창에서
>db2 list command options
>db2 connect to sample
>db2 select * from employee
>db2 ? -> 명령어 찾는 ..
ex) db2 ? create data
앞에다 db2 치기 싫으면 db2 먼저 치기!
명령 편집기 창에서
list command options
명령어 한 줄 한 줄 치기 귀찮으니까 메모장에 아래처럼 여러문장 치고
connect to sample;
drop table test;
create table test(col1 char(5));
insert into test (col1) values ('AAA');
insert into test (col1) values ('AAA');
insert into test (col1) values ('AAA');
insert into test (col1) values ('AAA');
insert into test (col1) values ('AAA');
terminate;
>db2 -stvf 파일이름.db2
종결문 바꿀 때
connect to sample@
drop table test@
create table test(col1 char(5))@
insert into test (col1) values ('AAA')@
insert into test (col1) values ('AAA')@
insert into test (col1) values ('AAA')@
insert into test (col1) values ('AAA')@
insert into test (col1) values ('AAA')@
terminate@
이렇게 하고
>db2 -td@ -vf 파일이름.db2
[PC] [서버] 프로토콜 ->TCP/IP
IP
Port -> 50000
ID, PW ->
커맨드 창에서
db2 catalog tcpip node 노드명 remote IP server 포트번호
포트번호 확인은 C:\WINDOWS\system32\drivers\etc 에서 services 파일 열기
db2 catalog database sample as testdb at node nodena
sample이라는 db를 testdb로 저장하겠당
db2 terminate
db2 connect to testdb user ID using PW
메모장에 한꺼번에..
catalog tcpip node nodename remote 192.168.182.130 server 50000;
catalog database sample as testdb at node nodename;
terminate;
>db2 -td@ -vf 파일이름.db2
>db2 connect to testdb user udba using udba;
terminate는 접속한 db를 끊는 것이고 접속되어 있지 않으면 refresh
>db2 list db directory
>db2 list node directory
>db2 uncatalog node 노드명
: 노드삭제
>db2 uncatalog db 디비명
: 디비삭제
>db2set -all
현재 무슨 옵션이 설정되어있나?
>db2set DB2COMM=TCPIP
->인터넷 안될 때?
>db2 get
>db2 set update dbm cfg using
>db2 update dbm cfg using svcename 50000
>db2 get db cfg
db에 접속 안하고 실행하려면
>db2 get db cfg ??????????
DB에서 테이블 스페이스에 매칭되는 버퍼풀(메모리)을 써서 성능향상시킴.
>db2 drop db sample
db2start: 인스턴스 메모리 공간 할당
db2stop : 인스턴스 메모리 공간 반납
>db2 diactivate database sample
-> 할당받았던 메모리 공간 지움..
>db2 lise tables for all
>db2 select
>db2 select * from syscat.tables fetch 10 rows only
(맨 앞에서 10줄만 보여달라~~)
>db2 describe table syscat.tables
>db2 list applications
>db2 force application(131)
핸들아이디
->강제 종료 명령어
>db2 create bufferpool bpools size 1024
->이 정도 사이즈의 버퍼풀을 만들겠따.
>db2 create tablespace 이름 managed by system using ('C:\tbs')
>db2 create tablespace 이름 managed by database using ('C:\DMS\tbs' 1000)
-> 경로안에 tbs란 파일이 생성됨
>db2 list tablespace containers for 4
테이블 확인 명령어
>db2 describe table test2
>db2look -d sample2 -a -o -x -e -l -o db2sample2.out
>db2 create unique index test1_u on test2 (col2)
(인덱스이름) (테이블명)
>db2 drop table table명
테이블보기
>db2 describe indexes for table test2
[유틸리티]
디비 연결 후(>db2 connect to 디비)
>db2 export employee.del of del select * from employee
>db2 export employee.ixf of ixf select * from employee
기존의 employee와 똑같이 만들어 주겠다
>db2 creaet table employee2 like employee
델타입의 employee를 employee2로 가져오겠다
>db2 import from employee.del of del insert into employee2
>db2 load from employee.del of del insert into employee2
>db2 import from employee.ixf of ixf create into employee3
//정리!!
설치
db2start
db2sampl (샘플 데이터 베이스 생성)
db2 create database
db2 connect to <데이터베이스>
db2 create bufferpool
db2 create tablespace
db2 create table
db2 create index
db2 export
db2 import, load (export 한 걸 다시 집어넣음)
원격 디비에 접속하기
catalog
(알아야할 것IP, port, database, id/pw, protocol)
catalog tcpip node <각 노드명> remote <서버 IP> server <포트번호>
catalog database <서버 DB명> as <리모트 DB명> at node <노드명>
->이 디비에 접속하겠다.
terminate
connect to <리모트 DB명> user <사용자명> using <패스워드>