• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Copy data from 2 or more tables in different DB's to a table in a different DB - SQLite

 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using SQ Lite DB. I have Table A in DB - 1 and Table B in DB - 2. I want to copy the contents of both tables to Table C in DB - 3, other than selecting each table and writing it to Table 3, is there any other commands that is useful for carrying out such process?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume all three of these tables have the same schema?

If so, you can export and import the data to transport it.
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks for the reply. I checked out the link you have provided. I need to do the copy using java.

PS: Sorry for not mentioning in my question
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can attach another database in SqlLite apparently.

http://stackoverflow.com/questions/6824717/sqlite-how-do-you-join-tables-from-different-databases

Incidentally, if you're moving data around in a database, try to find a way to do it in SQL first. Doing it in Java should usually be your last choice, not your first.
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,

Thanks for the reply. I will see the links. I am developing a java application and I need the copy to be automated. That is why i chose java to copy tables. Are there any other means to copy tables automatically?
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"To do it in SQL first" means to use SQL commands to copy the data if possible, for example useinstead of reading the source table using JDBC (resultset) and inserting individual rows into the target table. Using the SQL statement is much easier, much faster and less error prone.

You can still run the SQL command from Java. The "do it in SQL" doesn't mean you cannot use Java.
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin,

Thanks for the clarification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic