Hi there,
Is it possible to have a primary key - foreign key relationship between
tables in different databases in DB2 ? (databases are installed in
different physical servers)
Thanks a lot for your answers
Dov MORYUSEF 3 4091
This can be done trough federated server. However created constraint
cannot be ENFORCED. To use this feature, you have to enable Federated
Database System Support on both servers by issuing statement in Command
Window:
db2 update dbm cfg using FEDERATED YES
Next steps: create wrapper, server, nickname and at last create foreign
key which references created nickname.
--First server
CONNECT TO db_one user akalicki using ****;
CREATE TABLE akalicki.Test1 (col1 INT, col2 INT);
DISCONNECT db_one;
--Second server
CONNECT TO db_two user db_user using ****;
CREATE WRAPPER DRDA LIBRARY 'db2drda.dll' OPTIONS( ADD DB2_FENCED 'N');
CREATE SERVER DB_ONE TYPE DB2/UDB VERSION '8.2' WRAPPER DRDA AUTHID
"akalicki" PASSWORD "*****" OPTIONS( ADD DBNAME 'DB_ONE', PASSWORD
'Y');
CREATE USER MAPPING FOR "DB_USER" SERVER "DB_ONE" OPTIONS ( ADD
REMOTE_AUTHID 'akalicki', ADD REMOTE_PASSWORD '*****') ;
CREATE NICKNAME db_user.Test_ni ckname FOR DB_ONE.akalicki .Test1;
CREATE TABLE db_user.Test2 (col1 INT, col2 INT);
ALTER TABLE db_user.Test2
ADD CONSTRAINT CONST_FK FOREIGN KEY (col2)
REFERENCES db_user.Test_ni ckname (col1)
ON DELETE NO ACTION ON UPDATE NO ACTION
NOT ENFORCED ENABLE QUERY OPTIMIZATION ;
CONNECT RESSET;
Thanks for your answer.
In fact, my first server is DB2 UDB for iSeries V5R3 and second a DB2
UDB V8 for Linux. I have to adapt your commands to these platforms.
I will try it.
Many thanks.
Dov ad****@wp.pl a écrit : This can be done trough federated server. However created constraint cannot be ENFORCED. To use this feature, you have to enable Federated Database System Support on both servers by issuing statement in Command Window: db2 update dbm cfg using FEDERATED YES Next steps: create wrapper, server, nickname and at last create foreign key which references created nickname.
--First server CONNECT TO db_one user akalicki using ****; CREATE TABLE akalicki.Test1 (col1 INT, col2 INT); DISCONNECT db_one;
--Second server CONNECT TO db_two user db_user using ****;
CREATE WRAPPER DRDA LIBRARY 'db2drda.dll' OPTIONS( ADD DB2_FENCED 'N');
CREATE SERVER DB_ONE TYPE DB2/UDB VERSION '8.2' WRAPPER DRDA AUTHID "akalicki" PASSWORD "*****" OPTIONS( ADD DBNAME 'DB_ONE', PASSWORD 'Y');
CREATE USER MAPPING FOR "DB_USER" SERVER "DB_ONE" OPTIONS ( ADD REMOTE_AUTHID 'akalicki', ADD REMOTE_PASSWORD '*****') ;
CREATE NICKNAME db_user.Test_ni ckname FOR DB_ONE.akalicki .Test1;
CREATE TABLE db_user.Test2 (col1 INT, col2 INT);
ALTER TABLE db_user.Test2 ADD CONSTRAINT CONST_FK FOREIGN KEY (col2) REFERENCES db_user.Test_ni ckname (col1) ON DELETE NO ACTION ON UPDATE NO ACTION NOT ENFORCED ENABLE QUERY OPTIMIZATION ;
CONNECT RESSET;
If you'd like it to be enforced, perhaps you could CREATE the TABLE
locally and keep it in sync with the other database via a job (such as
every hour, day, or week).
B. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Paskoff |
last post by:
at first - can´t change the server version, so i have to live with the
limitations of the version.
since there is no ability to create queries between different
databases in this version - how can i cover my problem described
below?
i guess, one part of the solution is to use pgdump, but how to
continue?
|
by: Henri |
last post by:
Hello,
I am quite new to ms-sql and I have a problem : I want to create an SQL
request which would copy serveral records from a table in a given database
to another table (with exactly the same structure) in another database
(theses two tables and databases already exist).
Could you please tell me how to do this ? I dont know how to access two
different databases in a single SQL request.
|
by: Kenneth Fosse |
last post by:
Hi.
I'm currently working on a project which involves the creation of a
web page which reports selected data to customers from two back-end
systems. I use ASP script language on IIS, the server is MS SQL 2000.
Now I'm struggling with combining two tables from the different
databases. I'm sure it's simple enough, but I'm a little short on the
SQL expertise.
I've got two databases, db1 and db2, and then two tables, db1.t1 and
|
by: Captain Nemo |
last post by:
Hi
I'm working on an ASP project where the clients want to be able to
effectively perform SELECT queries joining tables from two different
databases (located on the same SQL-Server).
Does this involve creating virtual tables that link to another database, or
am I completely on the wrong track?
Any hints as to where I might find more information (buzz-words, etc.) would
|
by: cspowart |
last post by:
Consider first, table "A" :
Plate Make Model
=====================
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado
Then consider, table "B";
| |
by: =?Utf-8?B?VGVycnk=?= |
last post by:
Is it possible to join tables from different databases? If so, what is the
format of the select statement? Both databases are on the same server.
TIA,
--
Terry
|
by: asi242 |
last post by:
Hello,
Good day to all...
I just want to ask.. How would you connect two tables from 2 different databases using PHP scripts? Because, one database that contains customer table is dedicated to one project, and then here comes another project that also uses the customer table...the clients dont want to reenter all of values from the first database to the second database. Dumping would not be an option cause they want the two projects to run...
|
by: Aswanth |
last post by:
Hi..,
I'm having Two Stored Procedures in Two Different Databases..
Database1 - Employee
Stored Procedure - Employee_Details
Database2 - Company
Stored Procedure - Company_Details
|
by: sganeshsvk |
last post by:
sir,
i want to store the same data values in two different databases at that same time in mysql using php programming.
suppose any one databases data will lose then we use the other databases.
suppose there is any query for store the same data values in two different databases at the same time.
for eg:
databases sample1
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |