| Subcribe via RSS

Customize your DB2 CLP prompt

September 3rd, 2009 Posted in IBM DB2

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.

Tags: , , ,

3 Responses to “Customize your DB2 CLP prompt”

  1. Glasmow Says:

    Thanks for the tips, useful !


  2. SM2G Says:

    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 ;)


  3. Stéphane Journot Says:

    Of course, the prompt change every time you change database/instance/user !


Leave a Reply