Wednesday, 16 April 2014

Copying partition statistics (external link)

I have found today a very fresh article on the subject of copying the partition statistics. When copying, one have to understand which statistics are actually copied. E.g. in case of partitions one of concerns is how would like like the copied low and high values. Here (http://orastory.wordpress.com/2012/06/14/copy_table_stats/) You may find some paper touching that issue.

And 2 more:

Tuesday, 15 April 2014

DB2 backup howto

Disclaimer

I am absolute novice in the world of the DB2 database. Thus I incorporate both a complete ignorance and a fresh look at the same time ;-), so take it into consideration.

Preparations

# set log archives 
mkdir /db2arch
# the logarchmeth1 is a equivalent to the Oracle 
# log_archive_dest_1='LOCATION="/db2arch"'
db2 "update db cfg for BPMDB using logarchmeth1 disk:/db2arch/"
# this is about compression, but do not know the details
db2 "update db cfg for BPMDB using logarchcompr1 on"

# and here a check if all is set as expected
db2 "GET DATABASE CONFIGURATION FOR ${database}"
[..]
 First log archive method                 (LOGARCHMETH1) = DISK:/db2arch/
 Archive compression for logarchmeth1    (LOGARCHCOMPR1) = ON
 Options for logarchmeth1                  (LOGARCHOPT1) = 
 Second log archive method                (LOGARCHMETH2) = OFF
 Archive compression for logarchmeth2    (LOGARCHCOMPR2) = OFF
 Options for logarchmeth2                  (LOGARCHOPT2) = 
[..]

# after the preparations one have to perform once more a full backup offline
db2 "backup database ${database} to /db2backup"


Online backup operation

# load the profile 
. $HOME/sqllib/db2profile

# list databases
db2 list database directory 

# get database configuration
db2 "GET DATABASE CONFIGURATION FOR ${database}"

# the important parameters are:
# TRACKMOD, LOGARCHMETH1, LOGARCHMETH2, LOGARCHOPT1, LOGARCHOPT2
# I simply get them from the above command for configuration
# Because I want few of them, I call for all parameters, then grep, 
# but one may call only those of interest

# finally backup command
cmd="BACKUP DATABASE ${database} ONLINE"
if [ ${opt_tracking##*=} = 'YES' ]; then
  cmd="$cmd INCREMENTAL " ## here one may add also DELTA
fi
cmd="$cmd TO \"${BKP_DIR}\" "
cmd="$cmd WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 INCLUDE LOGS "
cmd="$cmd WITHOUT PROMPTING"
db2 "$cmd"

Monday, 14 April 2014

DBMS_REDEFINITION howto (external link)

http://www.ora-solutions.net/papers/Online_Redefinition_Oracle_10gR2.pdf - under this link one may find quite concise and thorough example of the DBMS_REDEFINITION package. Though a little bit old (version 10g R2), still it provides the MUST-KNOW content.