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

本文介绍如何在DB2控制台中自定义提示符,包括设置方法及使用预定义变量来显示实例名和数据库名等信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值