Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Windows
- Ravi
Database Creation
CREATE DATABASE
$ db2 create database TEST
DB20000I The CREATE DATABASE command completed successfully.
$ db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias
= TEST
Database name
= TEST
Local database directory
= /home/db2inst1
Database release level
= 10.00
Comment
=
Directory entry type
= Indirect
Catalog database partition number = 0
Alternate server hostname
=
Alternate server port number
=
$ db2 ? create database
If no path is specified when a database is created, the DB is created under DFTDBPATH
DFTDBPATH
Default database path configuration parameter
If no path is specified when a database is created, the DB is created under DFTDBPATH
DB2 UPDATE DBM CFG USING DFTDBPATH
/mnt/storage/DBPATH/
Note: DFTDBPATH should exist locally on the box. dont give any NFS mounted paths.
DB2 Object
SCOPE
Location
User: db2inst1
Product is installed in :
/opt/IBM/db2/v10.5 (INSTALLDIR)
Instance directory: /home/db2inst1
(INSTHOME)
DBPATH: /home/db2inst1
Instance
/home/db2inst1
Instance Information
Instance
/home/db2inst1/sqllib
Instance
INSTHOME/sqllib/db2systm
Database Directory,
which contains
Database
DBPATH/db2inst1/NODE0000/
SQL00001
Database
DBPATH/db2inst1/NODE0000
1/SQL00001/SQLDBCON
DB Configuration File
DB2 Commands
INSTALLDIR/bin
Instance
INSTHOME/sqllib/db2dump/db
2diag.log
Database
DBPATH/db2inst1/NODE0000/
SQL00001/db2event
SCOPE
Directory for transaction
logs (DB Specific)
Installation log file
Database
DBPATH/db2inst1/NODE0000/
SQL00001/LOGSTREAM0000
INSTALLDIR/install/logs/db2in
stall.history
Database
DBPATH/db2inst1/NODE0000/
sqldbdir
System database
directory
Instance
INSTHOME/sqllib/sqldbdir
Instance
INSTHOME/sqllib/sqlnodir
Partitioned database
environment file
Instance
INSTHOME/sqllib/db2nodes.cf
g
Node Directory
Connectivity information for remote database servers
$ db2 list node directory
$ db2 catalog tcpip node TCPFED remote 192.168.182.133 server 50000
$ db2 list node directory
Node Directory
Number of entries in the directory = 1
Node 1 entry:
Node name
Comment
Directory entry type
Protocol
Hostname
Service name
= TCPFED
=
= LOCAL
= TCPIP
= 192.168.182.133
= 50000
=0
= SYSCATSPACE
= Database managed space
= All permanent data. Regular table space.
= 0x0000
Tablespace ID
Name
Type
Contents
State
Detailed explanation:
Normal
=1
= TEMPSPACE1
= System managed space
= System Temporary data
= 0x0000
Tablespace ID
Name
Type
Contents
State
Detailed explanation:
Normal
=2
= USERSPACE1
= Database managed space
= All permanent data. Large table space.
= 0x0000
Tablespace ID
Name
Type
Contents
State
Detailed explanation:
Normal
=3
= SYSTOOLSPACE
= Database managed space
= All permanent data. Large table space.
= 0x0000
Tablespaces
(by space mangement)
=0
= /mnt/storage/sai/tbspace1
= Path
Tablespaces
(by Usage)
DB2 CLP
CLP SYNTAX
For example:
db2 ?
db2 ? command string
db2 ? SQLnnnn (nnnn = 4 or 5 digit SQLCODE)
db2 ? nnnnn (nnnnn = 5 digit SQLSTATE)
USING CLP
db2=> history
db2=> history reverse
db2=> h r
db2=> runcmd 9
db2=> r 9
db2=> edit 9
db2=> e 9
On top of system catalog tables, database manager creates two sets of system catalog views.
One set of read-only views is created under the SYSCAT schema, and a smaller set of
updatable views is created under the SYSSTAT schema
So,
SYSIBM: All catalog tables
SYSCAT: Useful read only views of catalog tables
SYSSTAT: Updatable views
db2 list tables for schema SYSCAT
db2 SELECT TABNAME from syscat.tables where tabschema = SYSCAT
db2 describe table syscat.systablespaces
db2 describe table syscat.sysbufferpools
BUFFERPOOLS
Area of main memory used to cache table and index data
Each database must have at least one buffer pool
Default: IBMDEFAULTBP
Buffer pools can be created, dropped, or altered
Query: SYSCAT.BUFFERPOOLS
Every table space must associate with the same buffer pool page size
A table space can only use one buffer pool
CREATE BUFFERPOOL bp8k PAGESIZE 8K
CREATE TABLESPACE tbsp1 PAGESIZE 8K BUFFERPOOL bp8k
SELECT BPNAME, BUFFERPOOLID, PAGESIZE FROM SYSCAT.BUFFERPOOLS
To get the buffer pool information:
db2look -d <Database Name> -l