DB2 cross-Database Access Table
Today, let's talk about how DB2 implements cross-database access to tables? It took a long time for me to test successfully, so I decided to share with you!
Okay, you don't have to talk about it anymore! Let's get down to the point. First you have to install the DB2 database, and then find the following position in the Start Menu:
Enter
Db2
Go to the db2 editing mode, as shown below:
The following command is executed in sequence:
Update dbm cfg using Federated YES; // enable joint database query
Db2stop force;
Db2start; // restart the database to take effect
Next, you need to connect to A specific database. For example, if there are database A and database B, now you want to access the table of database B in database, then, database A is connected.
Connect to [database name] user [user name] using [Password]
In this case, the [database name] Is database.
Execute the following commands in sequence:
Create wrapper drda; // create DRDA WRAPPER)
Create server [Database server alias] type db2/AIX version 9 wrapper drda authorization ["username"] password ["password"] options (dbname ['database name']); // create a SERVER)
Here, we name the database server alias B, which will be used later.
Create user mapping for ["username"] SERVER ["Database SERVER alias"] OPTIONS (REMOTE_AUTHID ['username '], REMOTE_PASSWORD ['Password']); // create user ing
Here, the database server alias should be B, which corresponds to the above.
Create nickname NK_Student for database server alias. username. Student; // nickname of table Creation
Here, the database server alias corresponds to B.
So far, you can access the Student table in database B in this way: select * from NK_Student.
This article permanently updates the link address: