1. Help
su - db2inst2
db2
db2 ==> ? (mọi lệnh của db2)
2. Stop a database
$ db2stop
$ db2stop force
3. Start a database:
$ db2start
4. Update config set archive log path:
$ db2 update db configuration for <db_name> using logarchmeth1 disk:/u01/db2/archivelog/
5. Update config set time to delete archivelog:
$ db2 update db configuration for <db_name> using REC_HIS_RETENTN 3
6. List active database:
$ db2 list active databases
7. Get config:
$ db2 get db cfg for <db_name>
8. List all DB:
$ db2 list db directory
9. Deactivate a database:
$ db2 deactivate db <db_name>
10. Activate a database
$ db2 activate db <db_name>
11. Get database manager config:
$ db2 get dbm cfg
-- Lấy alert log của DB2
$ db2 get dbm cfg |grep DIAGPATH
12. Get profile variable
$ db2set -all
13. Connect to a database:
$ db2 connect to <db_name>
14. Execute a SQL command:
$ db2 "select count(*) from dsrdbm01"
15. Disconnect from a database:
$ db2 terminate
16. Access db2 command line:
$ Db2
Db2> connect to <schema_nam>;
Db2> select schemaname from syscat.schemata
Db2> LIST TABLES FOR SCHEMA <schema_name>;
17. List backup history
$ db2 list history backup all for <db_name>
18. Get db size
CALL GET_DBSIZE_INFO(?, ?, ?, -1)
19. Create alias for existing database:
db2 catalog database DSRDBM01 as ldapdb2b
20. List active applications:
db2 list applications for database <db_name>
db2 list applications for database <db_name> show detail
21. List indexes of a table:
DESCRIBE INDEXES FOR TABLE <db_name>.ldap_entry SHOW DETAIL
22. Check tải
$ db2top
23. Kill app gây lock, app bị treo
$db2 force application (app_id)