Customize your DB2 CLP prompt
You have a nice DB2 CLP prompt, looks like “db2>”, but you want more, you want a efficient prompt. It is possible with DB2 to add or modify your CLP ! DB2 have a registry variable named DB2_CLPPROMPT which allows us to define the prompt to be used in the CLP interactive mode.
To define this variable, let’s use the DB2set command:
Db2set DB2_CLPPROMPT="db2isgreat> "
Our new DB2 Prompt will be “db2isgreat> “. It’s much more better, but we can do more. DB2_CLPPROMPT registry variable can contain the tokens %n, %ia, %d, %da and %i:
- %n – New line
- %ia – Authorization ID of the current instance attachment
- %d – Local alias of the currently connected database
- %da – Authorization ID of the current database connection
- %i – Local alias of the currently attached instance
Now, let’s try with these tokens:
Db2set DB2_CLPPROMPT="%ia@%i, %da@%d> "
With an instance attachment to instance “DB2″ with authorization ID “mycado”. Database “sample” with authorization ID “mycadoax”, will return something like:
MYCADO@DB2, MYCADOAX@SAMPLE >
You can now everytime where you are, and one which instance/database you’re working on.
September 3rd, 2009 at 1:46 pm
Thanks for the tips, useful !
September 3rd, 2009 at 4:54 pm
Will the prompt change automatically if I switch connection to another database or instance, or will it stick to the first parameter set I had when I first got connected ?
Best regards dear Mycado
September 3rd, 2009 at 6:04 pm
Of course, the prompt change every time you change database/instance/user !