Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL queries for distributed databases(need help now!)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have a slight problem with the SQL syntax for following issue:<br>I need to retrieve the name of those students who attends atleast two courses. The tables are allocated on two different databases, Site1 and Site2. The tables are Student, Course and Studies. Horizontal fragment Student1 of Student is allocated on Site1 and Site2.Horizontal fragment Student2 of Student is allocated on site2.<br>The table Course is not fragmented and is allocated on Site1. The same for table Studies. The user has no transparency .<br>Please help me as soon as possible,<br>Tankyou,<br>Maria(Sweden)<br>
 
Maria, what RDBMS are you using, and how are the two database instances distributed ?<br>In Oracle you might be able to do something involving creation of database links between the instances. The syntax is:<br>CREATE [SHARED] [PUBLIC] DATABASE LINK <i>dblink</i><br>[ CONNECT TO CURRENT_USER ¦&nbsp;&nbsp;<i>user</i> IDENTIFIED BY <i>password</i> ]<br>[ USING '<i>connect_string</i>' ] ;<br>e.g. <FONT FACE=monospace>create database link site2_scott connect to scott identified by tiger using 'world.site2_student_db';</font><br>You could then reference the remote table in a select statement as <i>site2_schema</i>.<i>student_table</i>@<i>site2_db_link</i> <br>e.g.<FONT FACE=monospace><br>select s1.id, s1.name from site1.student s1<br>union<br>select s2.id, s2.name from site2.student@site2_link s2;</font><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top