简体   繁体   English

从SQL Server迁移到ORACLE-如何处理临时表?

[英]Migrating from SQL Server to ORACLE ¿what to do with temporary tables?

Currently we use SQL Server and we have A LOT (read around 5.000) different scripts that create on the fly temporary tables. 当前,我们使用SQL Server,并且有许多(大约5.000个)动态运行的临时表创建的脚本。

Now we are migrating to ORACLE, so we cannot create on the fly temporary tables. 现在我们正在迁移到ORACLE,因此我们无法即时创建临时表。

Any ideas? 有任何想法吗?

Thanks in advance 提前致谢

You'd probably want to dynamically create the tables with an execute immediate whenever you need a temporary table: 每当需要临时表时,您可能希望动态地创建具有execute immediate表:

-- creating the table
begin 
  execute immediate q'!
    create table tmp_foo_bar ( 
       col_1 number,
       col_2 varchar2(50),
       etc   date
     ) !';
end;
/

-- using the table:
insert into tmp_foo_bar values (42, 'forty-two', sysdate);

-- dropping the table:
begin
  execute immediate 'drop table tmp_foo_bar';
end;
/

Oh boy, that is a lot of temporary tables. 哦,男孩,那是很多临时桌子。

Have you had a look at Oracle's SQL Developer tool ? 您是否看过Oracle的SQL Developer工具 It's free and it comes with a Migration Workbench which can help you with the journey. 它是免费的,并且带有一个迁移工作台,可以为您提供帮助。

With regards to temporary tables it appears that the OMWB will create temporary tables from the T-SQL statements. 关于临时表,似乎OMWB将根据T-SQL语句创建临时表。 Find out more . 了解更多

Caveat: I have never undertaken such a migration myself so I am not guaranteeing it. 警告:我本人从未进行过此类迁移,因此我不能保证。 But with 5000 scripts to migrate it has to be worth your while to evaluate it. 但是要迁移的脚本有5000个,因此值得您花时间对其进行评估。

What about Oracle Global Temporary Tables? 那么Oracle全局临时表呢?

CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  column1  NUMBER,
  column2  NUMBER
) ON COMMIT DELETE ROWS; -- or use ON COMMIT PRESERVE ROWS to keep data until the end of your session.

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

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