In windows cmd, you cannot directly run the db2 command. If you type db2 directly under cmd, an error is returned, "DB21061E has not initialized the command line environment ".
The solution is to type db2cmd, and then you can type db2.
In fact, some software must set environment variables during installation, but most of them are automatically added to the environment variables, which does not require additional operations for users. However, some of them must be set by yourself.
For example, when installing jdk, you need to set the environment variable yourself.
Db2 and oracle do not need to be set by ourselves. We can see in "My Computer ---- properties ---- advanced ---- environment variable ----- system variable,
The main bin directory of oracle is in ORACLE_HOME \ ora92 \ bin, while the main bin directory of db2 is in DB2_HOME \ SQLLIB \ BIN.
The difference is that oracle can directly run commands such as sqlplus and sqlldr in cmd, but db2 must first run db2cmd.
If you want to write the command as a. bat file and run it
> Xxx. bat is not acceptable.
> Db2cmd xxxx. bat.
Otherwise, your db2 will always report errors.
If you do not want cmd to identify the db2cmd command, you can remove the bin environment variable of db2 in path.
From Uncle Mao's rations