# file: docs/cheat-sheets/sql/db2/db2-cheat-sheet.sh
# to start db2
sudo /opt/ibm/db2/V10.5_01/adm/db2start
# to stop db2
sudo /opt/ibm/db2/V10.5_01/adm/db2stop
sudo /opt/ibm/db2/V10.5_01/adm/db2stop force
#how-to connnect to a database
db2 "connect to sample"
#db2
quit
# list all the tables
db2 "list tables for all " | less
# run a file
db2 -t -f ./path/to/file/run.sql | less
# use a different statement separator than the default ;
db2 -td/ -svf db2.sql
# get system info
db2 "SELECT * FROM TABLE(SYSPROC.ENV_GET_INST_INFO());" | less
# get db configuration
db2 "get db cfg for sample" | less
# run all the *table-insert* files under $dir
while read -r f ; do db2 -t -f $f; done < <(find $dir | grep insert-table | sort)
# src: http://dublintech.blogspot.fi/2011/10/db2-cheat-sheet.html
# src: http://www.michael-thomas.com/tech/db2/db2_survival_guide.htm
# eof file: docs/cheat-sheets/sql/db2/db2-cheat-sheet.sh