doyoudb2

DB2 UDB for LUW (Linux, Unix and Windows)

 
  • Increase font size
  • Default font size
  • Decrease font size

DB2_CLPPROMPT - Customize the db2 prompt

E-mail Print PDF
User Rating: / 1
PoorBest 
DB2 has a registry variable DB2_CLPPROMPT (much similar to the UNIX PS1 variable) which can be used to customize the db2 command line prompt.

The DB2_CLPPROMPT registry variable comes with associated variables that can be used to return information to the DB2 UDB CLP with respect to the current or default instance attachment and the currently connected (or default) database

Variables supported for CLP at runtime

Variable Value at runtime
%ia If an instance attachment exists, the authid of the current instance attachment; otherwise a null string.
%i If an instance attachment exists, the local alias of instance currently attached; if there isn't a local instance attachment, the value of the DB2INSTANCE or DB2INSTDEF registry variables; otherwise a null string.
%da If a database connection exists, the authorization ID of the current database connection; otherwise a null string.
%d If a database connection exists, the local alias of database currently connected; otherwise the value of the DB2DBDFT registry variable; otherwise a null string.
%n A newline character.


For example if you want to set your db2 prompt to display the current instance name and the database name, set the DB2_CLPPROMPT as:

db2set DB2_CLPPROMPT=" (Instance:%i, Database:%d):"


The db2 clp prompt in this case will be something like (assuming db2 instance is DB2INST and database is PRDDB:

(Instance:DB2INST, Database:PRDDB)


DB2 CLP prompt customization using DB2_CLPPROMPT registry variable could help you prevent life threatening situations like running a drop table command on a production box instead of a test box.

If you want more information about this registry variable and customizing the db2 command line prompt in general, you may find this article on IBM developerworks interesting.


Comments
Add New Search
+/-
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.

3.25 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Search Site

Subscribe

Enter your email address to receive new posts directly in your Inbox:

Relax! We hate SPAM as much as you do.

Sign In/Register

Syndicate Feeds - Subscribe



Related Articles