Home » SQL & PL/SQL » SQL & PL/SQL » Migration of three tables (oracle 10g)
Migration of three tables [message #594516] Thu, 29 August 2013 07:22 Go to next message
mahendra.s
Messages: 4
Registered: July 2013
Location: Bangalore
Junior Member

Hi all
Please help for data migration for three tables
I have three table which are
1.npi_p_mig contain four fields (pr_id,mi_id,qty,sl_dt,fac_code)
2.np_detail(pr_id,mil_id,qty,sl_dt,facility)
3.np_ref_tab(facility,fac_code),

I need to migrated the data from based on two tables (np_detail,np_ref_tab) to new table npi_P_mig(pr_id,mi_id,qty,sl_dt,fac_code) table..

i need sql script to migrate above two table to new table (npi_P_mig) ..please help to proceed future..

thanks!
Re: Migration of three tables [message #594517 is a reply to message #594516] Thu, 29 August 2013 07:39 Go to previous messageGo to next message
Littlefoot
Messages: 19885
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Based on what I see, you'd join NP_DETAIL and NP_REF_TAB by FACILITY column and insert the result into NPI_P_MIG.
Re: Migration of three tables [message #594518 is a reply to message #594517] Thu, 29 August 2013 07:44 Go to previous messageGo to next message
mahendra.s
Messages: 4
Registered: July 2013
Location: Bangalore
Junior Member

yes, i need to join two tables based on facility column and result of fac_cd i will put in npi_p_mig table .
please suggest how to right sql script for this.. thanks!
Re: Migration of three tables [message #594519 is a reply to message #594518] Thu, 29 August 2013 07:48 Go to previous messageGo to next message
Littlefoot
Messages: 19885
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
The simplest option is this:
insert into npi_p_mig (col1, ... )
select column_list_from_two_tables
from np_detail d, np_ref_tab r
where d.facility = r.facility
It might need adjustment, though (outer join, for example).
Re: Migration of three tables [message #594532 is a reply to message #594516] Thu, 29 August 2013 10:53 Go to previous message
Michel Cadot
Messages: 59991
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Previous Topic: Getting ORA : 00905 while synonym creation
Next Topic: Value of first and last sale
Goto Forum:
  


Current Time: Thu Dec 18 19:33:44 CST 2014

Total time taken to generate the page: 0.23388 seconds