Answer the question
In order to leave comments, you need to log in
Using Foreign Keys to join related tables to the main one?
Hello, I ran into a problem - I have to implement interaction with an existing system that uses the Oracle database. There are a bunch of basic tables with 80-100 columns, many of which contain keys for related tables, directories.
It is required to write a script that selects values from the main table, as well as values from related tables - that is, opened the reference books.
The task is trivial in theory and would be easily done by hand, if it were not for the deadlines and such a huge amount of tables and fields.
Maybe there is a functionality in oracle that can join related tables, or a 3d party tool that will help generate the necessary script.
I think a couple of illustrations will not hurt - I threw in an example:
Main table:
Its limitations:
External table:
The result is similar to the one below:
<font color="black"><font color="#0000ff">Select</font> m.id,<br/> first_field,<br/> second_field,<br/> --прикреплённая табличка<br/> s.short_name <font color="#0000ff">as</font> second_field_short_name,<br/> s.long_name second_field_long_name,<br/> s.amount <font color="#0000ff">as</font> second_field_amount third_field,<br/> fourth_field,<br/> fifth_field,<br/> <br/> <font color="#0000ff">from</font> a_maintable m<br/> <font color="#0000ff">left</font> <font color="#0000ff">join</font> a_ref_second s<br/> <font color="#0000ff">on</font> m.second_field = s.ID</font><br/> <br/> <font color="gray">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><font color="gray">Source Code Highlighter</font></a>.</font>
Answer the question
In order to leave comments, you need to log in
Install some EMS, generate a common table and then for each template generate SELECT INTO or just insert with a subquery ... Or I misunderstood you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question