Copy table from one database to another

/ Published in: XML
Save to your folder(s)

This Scriptella ETL script copies all rows from Src_Table to Dest_Table.
Src_Table contains the following columns: id, first_name, last_name
Dest_Table contains the following columns: id, name
The name column of the Dest_Table is produced by a concatenation of first_name and last_name from the Src_Table
This example demonstrates HSQLDB-To-Oracle copy procedure, although it works between virtually any databases.

Copy this code and paste it in your HTML
  1. <!DOCTYPE etl SYSTEM "">
  2. <etl>
  3. <connection id="in" driver="hsqldb" url="jdbc:hsqldb:file:demo"
  4. classpath="hsqldb.jar" user="sa"/>
  5. <connection id="out" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:ORCL"
  6. classpath="ojdbc14.jar" user="scott" password="tiger"/>
  7. <!-- Copy all table rows from one to another database -->
  8. <query connection-id="in">
  9. SELECT * FROM Src_Table --Selects all rows
  10. <!-- For each row executes insert -->
  11. <script connection-id="out">
  12. INSERT INTO Dest_Table(ID, Name)
  13. VALUES (?id,?{first_name+' '+last_name})
  14. </script>
  15. </query>
  16. </etl>


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.