Here's the BRIDGE command in sqldev/sqlcl that could help. This command takes in the 3 parameters
- The name of the new local table to create
- The full connect details to a remote database.
- The sql to issue on the remote side.
When executed the tool will connect via jdbc to the remote database. Issue the sql. Retrieve the structure of the query to get the metadata to create the local new table specified. Then batch insert into the local table as it iterates the resultset of the remote query.
Caution! This command creates the table only. Any indexes will need to be added manually.
Here's a full example:
sql jeff/jeff
SQLcl: Release 18.1 Production on Thu Feb 08 10:40:46 2018
JEFF@xe>tables
**TABLES**
DEPT
JEFF@xe>BRIDGE emp as "jdbc:oracle:thin:klrice/klrice@localhost:1521:xe"(select * from emp);
Created table emp and inserted 14 rows
JEFF@xe>tables
**TABLES**
DEPT
EMP
JEFF@xe>select ename,dname
2 from emp,dept
3 where emp.deptno = dept.deptno;
ENAME DNAME
KING ACCOUNTING
BLAKE SALES
CLARK ACCOUNTING
JONES RESEARCH
SCOTT RESEARCH
FORD RESEARCH
SMITH RESEARCH
ALLEN SALES
WARD SALES
MARTIN SALES
TURNER SALES
ADAMS RESEARCH
JAMES SALES
MILLER ACCOUNTING
14 rows selected.