• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Migration of data one table to other

HI

TABLE A(SOURCE TABLE)

SSC_ID                  ID              G_ID     V_ID     LAST_MODIFIED_DATE  <<Columns in table

Sequnec.nexval  1 to1000           8         12             timestamp

TABLE B (TARGE TABLE)

SSC_ID                  ID             G_ID   V_ID      LAST_MODIFIED_DATE  <<Columns in table

Sequnec.nexval  1 to1000           8     12             timestamp

I want to migrate all data from table A to table A if TABLE A(Source table) data is old(timestamp) then TABLE B(Target Table)

with where clause(g_id 8 and v_id 12 only data)

Thanks
0
vadicherla
Asked:
vadicherla
  • 5
  • 4
1 Solution
 
OP_ZaharinCommented:
- what do you mean by " if TABLE A(Source table) data is old(timestamp)"? the LAST_MODIFIED_DATE   need to be compared with which date?

- if the column in TABLEB is the same as TABLEA:

INSERT INTO tableB SELECT * FROM tableA
WHERE G_ID = 8
AND V_ID = 12
0
 
OP_ZaharinCommented:
- if you mean "data is old" from today date then use the following:

INSERT INTO tableB SELECT * FROM tableA
WHERE G_ID = 8
AND V_ID = 12
AND LAST_MODIFIED_DATE < SYSDATE
0
 
vadicherlaAuthor Commented:
we have timestamp data in last_modified_date column.. i want want to migrate only old data based on timestamp from source to target.  If data in target table is old just ignore those data and migration old data
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
vadicherlaAuthor Commented:
its not based on sysdate, its based on last_modified_date in both the tables
0
 
OP_ZaharinCommented:
- try this:

INSERT INTO tableB  
SELECT * FROM tableA a
WHERE a.G_ID = 8
AND a.V_ID = 12
AND EXISTS
(SELECT tableB b
WHERE b.G_ID = a.G_ID  
AND b.V_ID = a.V_ID
a.LAST_MODIFIED_DATE < b.LAST_MODIFIED_DATE)
0
 
OP_ZaharinCommented:
- i left out the SELECT * FROM tableB:

INSERT INTO tableB  
SELECT * FROM tableA a
WHERE a.G_ID = 8
AND a.V_ID = 12
AND EXISTS
(SELECT * FROM tableB b
WHERE b.G_ID = a.G_ID  
AND b.V_ID = a.V_ID
a.LAST_MODIFIED_DATE < b.LAST_MODIFIED_DATE)
0
 
OP_ZaharinCommented:
- or this is to find the latest date in tableB for comparison then insert:

INSERT INTO tableB  
SELECT * FROM tableA a
WHERE a.G_ID = 8
AND a.V_ID = 12
AND a.LAST_MODIFIED_DATE <
(SELECT MAX(LAST_MODIFIED_DATE) FROM tableB b
WHERE b.G_ID = 8  
AND b.V_ID = 12
GROUP BY b.G_ID, b.V_ID)

0
 
vadicherlaAuthor Commented:
Ah i was tring same query but not iwth EXISTS  in command.. Anyway thanks a lot for help

i will close the ticket on monday.
0
 
QlemoC++ DeveloperCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
vadicherlaAuthor Commented:
thanks for soluation
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now