springboot-load-a-h2-table-from-an-oracle-database

169 views
Skip to first unread message

Deepak Gunasekaran

unread,
Jun 1, 2021, 6:35:10 AM6/1/21
to H2 Database
Hello All,

In a spring boot application startup, i would like to populate a table in the in memory H2 database from a table in oracle database.

Is there an out of the box way to do this ? I am going over configuring multiple data bases with spring : Spring Boot Configure and Use Two DataSources

but all i need is one time load from oracle table into H2 table. So is there a cleaner way to do this? 


Apart from initialisation, i don't need oracle table any further. 


Thank you! 

-Deepak 

Evgenij Ryazanov

unread,
Jun 1, 2021, 8:16:52 AM6/1/21
to H2 Database
Hello.

You can register a linked table
and create its copy as a normal table with
CREATE TABLE tableName AS TABLE linkedTableName
After that the linked table may be dropped.
Indexes and constraints will not be copied, so if they're needed, you need to create them separately.

Deepak Gunasekaran

unread,
Jun 1, 2021, 8:01:03 PM6/1/21
to H2 Database
Thank you , is there an example for this usage in spring , where do i configure the linked table in spring boot. 
Reply all
Reply to author
Forward
0 new messages