简体   繁体   English

动态 SSIS 包从 Oracle 加载 N 个表到 SQL

[英]Dynamic SSIS package to load N tables from Oracle to SQL

We have N tables on Oracle server and we wanted to load all those tables from Oracle to SQL server.我们在 Oracle 服务器上有 N 个表,我们想将所有这些表从 Oracle 加载到 SQL 服务器。 We are creating dynamic SSIS packages for same which will take the Oracle ServerName, DB name, schema name, tables list etc. and will load all these tables to SQL server.我们正在为其创建动态 SSIS 包,它将采用 Oracle ServerName、DB 名称、模式名称、表列表等,并将所有这些表加载到 SQL 服务器。 We have added Link Server on SQL Server (SSMS) for Oracle.我们在 SQL Server (SSMS) 上为 Oracle 添加了链接服务器。

But we are not getting the efficient way to do the same.但是我们没有得到有效的方法来做同样的事情。 How we can achieve this in a single SSIS package.我们如何在单个 SSIS 包中实现这一点。 How we can handle metadata of Oracle tables and creating the same on SQL server ?我们如何处理 Oracle 表的元数据并在 SQL 服务器上创建相同的元数据? This SSIS package should create tables dynamically on SQL server as well , for this we tried Temp table in SSIS package.这个 SSIS 包也应该在 SQL 服务器上动态创建表,为此我们尝试了 SSIS 包中的临时表。

Since you have to do it with a large number of tables, I'd write a pl/sql procedure something, built around something like this:由于您必须使用大量表来执行此操作,因此我会编写一个 pl/sql 过程,围绕以下内容构建:

declare v_sql varchar2(1024);声明 v_sql varchar2(1024);

begin
for x in (select owner, table_name from dba_tables where .....)
  v_sql := 'created table '||
           table_name ||
           '@mssql a select * from '||
           x.owner || '.' || x.table_name || ';';
  exec immediate v_sql;
end loop;
end;
/

or, if you want to look it over before launching, use sql to write sql.或者,如果你想在启动之前查看它,使用sql来编写sql。 In sqlplus:在 sqlplus 中:

set echo off feedback off verify off trimsp on pages 0
spool doit.sql
select 'create table '||
        table_name ||
        '@mssql as select * from '||
        owner || '.' || table_name || ';'
from dba_tables
where .....
;
spool off

then check the spooled sql file for any issues before running.然后在运行之前检查假脱机的 sql 文件是否有任何问题。

All code above is off the top of my head.上面的所有代码都在我的脑海中。 There may be minor syntax issues.可能存在轻微的语法问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM