db2_notes

Upload: nj-singh

Post on 10-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/22/2019 db2_notes

    1/3

    DATABASE NAME: db2testINSTANCE NAME: DB2INST1USER: RAJNI,NEERAJ

    citi - [email protected] --- permanent increase --permanent increawanz - [email protected] "Attention To Credit Authorization"uob -- [email protected] UOB Preferred Platinum Visa Card

    Your application for ANZ Switch Platinum Credit Card has been successfully submitted.Your reference number for the application is CPA0012621

    [root@r5o11asm ~]# useradd -g sysctl -d /db2/neeraj neeraj[root@r5o11asm ~]# cd /db2/rajni/[root@r5o11asm rajni]# lsdb2query.txt[root@r5o11asm rajni]# cp .bash_profile /db2/neerajcp: overwrite `/db2/neeraj/.bash_profile'? y[root@r5o11asm rajni]# passwd neerajChanging password for user neeraj.

    New UNIX password:BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password:passwd: all authentication tokens updated successfully.

    [neeraj@r5o11asm ~]$ db2 attach to db2inst1

    Instance Attachment Information

    Instance server = DB2/LINUX 9.5.0Authorization ID = NEERAJLocal instance alias = DB2INST1

    [rajni@r5o11asm ~]$ db2 update dbm cfg using SYSCTRL_GROUP sysctl[rajni@r5o11asm ~]$ db2 get dbm cfg | grep -i sys[neeraj@r5o11asm ~]$ db2 attach to db2inst1[neeraj@r5o11asm ~]$ db2 list active databases

    [neeraj@r5o11asm ~]$ db2 "create table neeraj.test (id integer)";[neeraj@r5o11asm ~]$ db2 "create table neeraj.test (id integer)";[neeraj@r5o11asm ~]$ db2 "select * from test WITH UR";

    [neeraj@r5o11asm ~]$ db2 get db cfg |grep -i logFirst log archive method (LOGARCHMETH1) = OFF

    ****************TAKE DB2 DATABASE IN ARCHIVE LOG MODE:********************************db2 "backup db db2test to /db2/archive"db2 update db cfg for db2test using LOGARCHMETH1 DISK:/db2/archivedb2 "ARCHIVE LOG FOR DATABASE db2test"

    TAKE BACKUP:1> Before backing up a database, make sure to have one of the following authorit

  • 7/22/2019 db2_notes

    2/3

    ies on DB2:SYSADMSYSCTRLSYSMAINT

    2>connect to the database . make sure no other applications are connected to the databasewhen performing an offline backup or you will receive an SQL1035N error message.DB2 "list applications" and DB2 "force applications all" are useful commands forthistask

    TYPES OF BACKUPS:1> The first is an offline database backup:This type of backup requires an exclusive

    connection to the database since all tablespaces in the database will be backed up.2> The second type is an online database backup.Note: If performing an online backup, make sure the rollforward recovery parameterlogretain = on or userexit** is enabled in the database configuration file.If it is not, you will receive an SQL2413N error

    and will need to perform the following commands:db2 "update database configuration for [database name] using logretain on" > db2stop > db2start

    db2 "get database configuration for DB2TEST"DB2 "GET DB CFG FOR DB2TEST"

    [neeraj@r5o11asm ~]$ db2 list active databases

    Active Databases

    Database name = DB2TESTApplications connected currently = 0Database path = /db2/database/db2inst1/NODE0000/SQL00001/

    [neeraj@r5o11asm ~]$ db2 force application(13)

    SELECT * FROM sysibmadm.tbsp_utilization WITH ur

    CREATE TABLESPACE NEERAJ MANAGED BY DATABASE

    USING (FILE '/db2/database/db2inst1/NODE0000/DB2TEST/' 10M)

    /db2/database/db2inst1/NODE0000/DB2TEST/T0000004/C0000000.UTM

    *************VIEWS

  • 7/22/2019 db2_notes

    3/3

    SELECT * FROM sysibmadm.ADMINTABINFO WITH ur: =DBA_SEGMENTS

    TABNAMETABSCHEMATABTYPEDATAPARTITION_ID

    SELECT * FROM sysibmadm.CONTAINER_UTILIZATION /SNAPCONTAINER WITH ur : IS USED TO CHECKTABLESPACE NAME : TBSP_NAMEDATAFILE(CONTAINER LOC) : CONTAINER_NAME

    SELECT * FROM sysibmadm.TBSP_UTILIZATION WHERE TBSP_ID=5 WITH ur

    db2look -d db2test -e -a -o db2look_db2test.sql

    db2look -d db2test -z neeraj -e -a -o db2look_db2test_neeraj.sql

    db2look -d db2test -z neeraj -t test1 -e -a -o db2look_db2test_neeraj_test1.sql

    [rajni@r5o11asm ~]$ db2 " grant load on database to user neeraj";

    db2 backup database db2test user neeraj using neeraj tablespace neeraj online to'/dev/null'

    Backup successful. The timestamp for this backup image is : 20130802171630

    [neeraj@r5o11asm ~]$ db2 backup database db2test tablespace neeraj online to '/dev/null'

    db2 "create database db2saan"