永久设置 DB2CLP 环境变量

Permanently set DB2CLP environment variable

我的 DB2CLP 环境变量有问题,在 Windows 7 64,IBM_client64_V97(与 DB2 连接)。

每次我在 Windows 命令提示符 window 中尝试 DB2 时,我都会收到此错误:

DB21061E 命令行环境未初始化。

并且每个 this 文档仅使用此步骤:

2. at the prompt enter these commands:
db2cmd -i -w db2clpsetcp 
echo %DB2CLP%

我修复了那个错误,"db2" 命令打开了 DB2 客户端的命令行处理器。 但它只持续到 windows CMD 打开。一旦我关闭它并重新打开它,我必须重复这个过程。

我的问题(作为 DB2 的新手)是:

  1. 我应该如何使更改永久化并且
  2. 当我根据手册(包括将本地用户添加到 DB2USERS 和 DB2ADMINS)组安装和设置所有内容时,这首先是怎么发生的?

安装 DB2 客户端时,它应该已经为命令行处理器安装了一个功能性 window。在这里查看:

开始/所有程序/IBM DB2/DB2copy1/命令行处理器

请注意,DB2copy1 是第一个 db2 实例的默认位置。如果用户 select 非默认名称,名称可能不同。

可以在桌面上复制 CLP 的快捷方式。

关于在windows命令提示符中输入"DB2 ..some command..."导致所述错误解释如下:

That's because the normal DOS (or Windows) prompt doesn't automatically run the setup script that enables the DB2 commands. When the setup runs, it puts the DB2 items first in the PATH variable. That could conflict with other tools that also want to be first on the search list.

If you've got both the DOS (Windows) and DB2 command line prompts on your desktop, right click them and select Properties. You'll notice that the system (DOS) prompt runs cmd.exe.

The DB2 prompt runs DB2CMD.exe from the DB2 libraries. The DB2 script then runs DB2SETCP.BAT and finally DB2.EXE. (All of the DB2 executables should be in C:\Program Files\IBM\SQLLIB\BIN.)

So there are differences in the two prompts. For you purposes, try running DB2SETCP.BAT from the normal DOS prompt. That may be sufficient for your needs.

For my purposes I always have the DOS and DB2 prompts on my desktop and just select the one that I need.