1

我是 PL/SQL 的新手,我需要从 3 个表创建一个临时表,并且记录集可用于报告,我只需要在会话期间进行记录。我想知道什么是最好的方法,因为我听说临时全局表不是最好的选择。

  • 表格1:fields t1.pnum, t1.dnum t1.amount, t1.c_amount
  • 表2:fields t2.pnum, t2.dnum t2.amount, t2.c_amount
  • 表3:fields t3.pnum, t3.dnum t3.amount, t3.c_amount

其中 table2 和 table3 结果由 pnum 联合到 table1

4

1 回答 1

1

You create the global temporary table as a regular schema object, not "on the fly" with PL/SQL. Then you insert into it and select from it. The data you nsert is only visible to your session, and when you either commit or disconnect or delete the data, it is gone.

However, are you sure that you need it? You can often do without a GTT in favour of Common Table Expressions (WITH clauses).

于 2013-10-15T21:40:38.733 回答