DB2 cross-Database Access Table

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.