Adsense

Thursday, September 18, 2014

DB2 Basic Commands with Example

DB2 Basic Commands

1. db2cmd -  Opens db2 command window

2. db2start   - to start the database manager instance

3. db2stop  -  to stop the database manager instance

4. db2stop force - to stop the database manager instance forcefully

5. db2cc - starts the db2 control center

6. db2 list db directory - lists all the databases created in the db server

          -To list databases that start with "SAL"
                Linux : db2 list db directory | grep -i "SAL"
               Windows :  db2 list db directory | find /i "SAL"

7. db2 list tables -  lists all the tables of a connected database
         
          -To list tables that start with "EMP"

                Linux : db2 list tables | grep -i "EMP"
               Windows :  db2 list tables | find /i "EMP"

8. db2 list applications - lists the applications connected
             
           - To count number of applications connected

                   Linux : db2 list applications | grep -c DB2INST1
                   Window: db2 list applications | find /c "SCHEMA NAME'

9. db2 get db cfg - displays the configurations of the connected database.

             -To display configurations related to LOG

                  Linux : db2 get db cfg | grep -i LOG
                  Windows: db2 get db cfg | find /i "LOG"
             

10. db2 get db cfg for databasename - displays the configurations of a database mentioned.

11. db2 get dbm cfg - shows the database level configuration settings

12. db2 terminate -  ends the process the server held open to the client, and drops all resources

13. db2 connect reset - stops the connection to database COMMITs the database.

14. db2licm -l  - displays  the db2 licence details

15. db2 activate db 


16. db2level -  shows the db2 Version detail

17. db2 CALL GET_DBSIZE_INFO(?, ?, ?, -1) -  to get the size of the database sizelists SNAP SHOT TIMESTAMP, DATABASE SIZE, DATABASE CAPACITY


18. db2 list command options - displays the available  Command Line Processor (DB2CMD) settings.


Database creation & Backup Restore Commands:

1. db2 create db databasename  - creates the database

2. db2 create db databasename using codeset utf-8 territory us collate using system - creates the database with utf-8 support

3. db2 backup db dbname - to make offline backup of the database

4. db2 restore db databasename taken at timestamp into sourcedb replace existing -  to restore the database backup into source database.

5. db2move databasename export -  exports the data

6. db2move dbname import  - imports the exported data to the database

7. db2 list history backup all for databasename -shows recent backups and where they are stored

8. db2ckbkp dbimage name -checks the integrity of a backup image

9. db2 restore db incremental automatic taken at - Restores from incremental backup automatic

10. db2ckrst -d -t  - to restore an incremental backup manually this command will give you the required previous backups.

11. db2 list table spaces  -lists all the table spaces of a connected database


0 comments:

Post a Comment