简体   繁体   English

pl / sql创建临时全局表

[英]pl/sql Creating temporary global tables

I am new to PL/SQL and I need to create a temp table from 3 tables and the record set be available for a report, I need the recorset only for the duration of the sesion. 我是PL / SQL的新手,我需要从3个表中创建一个临时表,并且该记录集可用于报告,我只需要在会议期间重新设置。 I would like to know what is the best way since I had heard that temporary global tables are not the best option. 我想知道什么是最好的方法,因为我听说临时全局表不是最好的选择。

  • table1: fields t1.pnum, t1.dnum t1.amount, t1.c_amount table1: fields t1.pnum, t1.dnum t1.amount, t1.c_amount
  • table2: fields t2.pnum, t2.dnum t2.amount, t2.c_amount table2: fields t2.pnum, t2.dnum t2.amount, t2.c_amount
  • table3: fields t3.pnum, t3.dnum t3.amount, t3.c_amount fields t3.pnum, t3.dnum t3.amount, t3.c_amountfields t3.pnum, t3.dnum t3.amount, t3.c_amount

where table2 and table3 results union to table1 by pnum 其中table2和table3结果通过pnum联合到table1

You create the global temporary table as a regular schema object, not "on the fly" with PL/SQL. 您将全局临时表创建为常规模式对象,而不是使用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). 通常,在没有GTT的情况下,您可以使用通用表表达式(WITH子句)。

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

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