While responding to a review/followup, it would be really good if you could give use the Database version. We don't have any clue about your environment details (is that on 12.1.0.1 or 12.1.0.2) ?
Below test is from 12.1.0.2 on both Multitenant and non-CDB Architecture.
I don't see reduced undo after setting TEMP_UNDO_ENABLED=TRUE.
Do i need to re-connect the session before setting TEMP_UNDO_ENABLED=TRUE? is that mandatory ?Non-CDB Architecturerajesh@ORA12C> select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for 64-bit Windows: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
5 rows selected.
rajesh@ORA12C>
rajesh@ORA12C> select name,cdb,con_id
2 from v$database ;
NAME CDB CON_ID
---------- --- ----------
ORA12C NO 0
1 row selected.
rajesh@ORA12C>
rajesh@ORA12C> drop table gtt purge;
drop table gtt purge
*
ERROR at line 1:
ORA-00942: table or view does not exist
rajesh@ORA12C> create global temporary table gtt(x char(100))
2 on commit preserve rows;
Table created.
rajesh@ORA12C>
rajesh@ORA12C> insert into gtt(x)
2 select 'x' from dual
3 connect by level <=10000;
10000 rows created.
rajesh@ORA12C> commit;
Commit complete.
rajesh@ORA12C> update gtt set x = 'y';
10000 rows updated.
rajesh@ORA12C>
rajesh@ORA12C> select used_ublk,used_urec
2 from v$transaction t1,
3 v$session t2
4 where t1.ses_addr = t2.saddr
5 and t2.audsid = sys_context('userenv','sessionid');
USED_UBLK USED_UREC
---------- ----------
303 10589
1 row selected.
rajesh@ORA12C> commit;
Commit complete.
rajesh@ORA12C>
rajesh@ORA12C> alter session set temp_undo_enabled=true;
Session altered.
rajesh@ORA12C> update gtt set x = 'z';
10000 rows updated.
rajesh@ORA12C>
rajesh@ORA12C> select used_ublk,used_urec
2 from v$transaction t1,
3 v$session t2
4 where t1.ses_addr = t2.saddr
5 and t2.audsid = sys_context('userenv','sessionid');
USED_UBLK USED_UREC
---------- ----------
221 589
1 row selected.
rajesh@ORA12C> commit;
Commit complete.
rajesh@ORA12C>
Multi-Tenant Architecturerajesh@PDB1> select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production
TNS for 64-bit Windows: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
5 rows selected.
rajesh@PDB1>
rajesh@PDB1> select name,cdb,con_id
2 from v$database ;
NAME CDB CON_ID
---------- --- ----------
CDB1 YES 0
1 row selected.
rajesh@PDB1>
rajesh@PDB1> create global temporary table gtt(x char(100))
2 on commit preserve rows;
Table created.
rajesh@PDB1> insert into gtt(x)
2 select 'x' from dual
3 connect by level <=10000;
10000 rows created.
rajesh@PDB1> commit;
Commit complete.
rajesh@PDB1>
rajesh@PDB1> update gtt set x = 'y';
10000 rows updated.
rajesh@PDB1>
rajesh@PDB1> select used_ublk,used_urec
2 from v$transaction t1,
3 v$session t2
4 where t1.ses_addr = t2.saddr
5 and t2.audsid = sys_context('userenv','sessionid');
USED_UBLK USED_UREC
---------- ----------
221 589
1 row selected.
rajesh@PDB1> commit;
Commit complete.
rajesh@PDB1>
rajesh@PDB1> alter session set temp_undo_enabled=true;
Session altered.
rajesh@PDB1>
rajesh@PDB1> update gtt set x = 'z';
10000 rows updated.
rajesh@PDB1>
rajesh@PDB1> select used_ublk,used_urec
2 from v$transaction t1,
3 v$session t2
4 where t1.ses_addr = t2.saddr
5 and t2.audsid = sys_context('userenv','sessionid');
USED_UBLK USED_UREC
---------- ----------
221 589
1 row selected.
rajesh@PDB1>