0
点赞
收藏
分享

微信扫一扫

DB2 tip -- Customize the prompt of your db2's console.


Tip 1.  Specify the word in your db2 console.

 

While you come into db2 console. The console will display the prompt in this system. The default word of dbs console's prompt is DB2=>.  As you see, it is very plain, and can not give our more information about the current connection. But DB2 command provide a way to change it. The console's prompt can be configurated by the option of DB2 system environment. The option is DB2_CLPPROMPT. The value of this option is not set, therefore the word is DB2=>. You can set the value of its as you want. For example db2set DB2_CLPPROMPT='SQL=>', then you will find the prompt of console is changed after you run db2 command. It likes this 'SQL=>'. The value can use some variable character which is pre-defined into db2set command like '%d', '%i', ’%ia' and '%a'

 

The explanation about them is blow:

%i  the instance's name if you connected, otherwise is null.

%ia  the instance's authid if you connected, otherwise is null.

%d  the database's name if you connected, otherwise is null.

%da  the database's authid if you connected, otherwise is null.

 

Sample

[db2inst1@dxzq10 ~]$ db2set DB2_CLPPROMPT='SQL=>'

[db2inst1@dxzq10 ~]$ db2

SQL=>

 

[db2inst1@dxzq10 ~]$ db2set DB2_CLPPROMPT='%d@%i =>'

[db2inst1@dxzq10 ~]$ db2

@DB2INST1 =>   --- you have never connect any database, therefore the name of database is not given.

@DB2INST1 =>list database directory;
 
 System Database Directory
 
 Number of entries in the directory = 1
 
Database 1 entry:
 
 Database alias                       = TOOLSDB
 Database name                        = TOOLSDB
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

@DB2INST1 =>connect to toolsdb;
 
   Database Connection Information
 
 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TOOLSDB

TOOLSDB@DB2INST1 =>

 

Now after you connect the toolsdb database. The prompt is changed to be TOOLSDB@DB2INST1, and the 'TOOLSDB' is the database's name, and 'DB2INST1' is the instance's name.

 

That's all. Enjoy it.

 

 

 

举报

相关推荐

0 条评论