begin
for i in ( select table_name
from user_private_temp_tables
where owner = sys_context('USERENV','CURRENT_USER')
)
loop
begin
execute immediate 'drop table '||i.table_name;
exception
when others then null;
end;
end loop;
end;
Statement processed.
create private temporary table MY_TT ( x int )
ORA-00903: invalid table nameMore Details: https://docs.oracle.com/error-help/db/ora-00903
create private temporary table ORA$PTT_MY_TT ( x int )
Table created.
create table ORA$PTT_MY_NORMAL_TABLE ( y int )
ORA-32463: cannot create an object with a name matching private temporary table prefixMore Details: https://docs.oracle.com/error-help/db/ora-32463
select count(*)
from all_objects
where object_name = 'ORA$PTT_MY_TT'
COUNT(*) | 0 |
---|
commit
Statement processed.
select * from ORA$PTT_MY_TT
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create private temporary table ORA$PTT_MY_TT ( x int )
on commit preserve definition
Table created.
insert into ORA$PTT_MY_TT
select rownum from dual
connect by level <= 30
30 row(s) inserted.
commit
Statement processed.
select count(*) from ORA$PTT_MY_TT
COUNT(*) | 30 |
---|
exec dbms_stats.gather_table_stats('','ORA$PTT_MY_TT')
ORA-20000: Unable to analyze TABLE "SQL_PSUOAPSCOLIVJEYXWUCPTXUWU"."ORA$PTT_MY_TT", insufficient privileges or does not exist ORA-06512: at "SYS.DBMS_STATS", line 39094 ORA-06512: at "SYS.DBMS_STATS", line 38371 ORA-06512: at "SYS.DBMS_STATS", line 38530 ORA-06512: at "SYS.DBMS_STATS", line 39076 ORA-06512: at line 1 ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-20000
delete plan_table
5 row(s) deleted.
explain plan for select count(*) from ORA$PTT_MY_TT
Statement processed.
select * from dbms_xplan.display()
PLAN_TABLE_OUTPUT | Plan hash value: 782278473 | ------------------------------------------------------------------------------------ | | Id | Operation | Name | Rows | Cost (%CPU)| Time | | ------------------------------------------------------------------------------------ | | 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 | | | 1 | SORT AGGREGATE | | 1 | | | | | 2 | TABLE ACCESS STORAGE FULL| ORA$PTT_MY_TT | 30 | 2 (0)| 00:00:01 | | ------------------------------------------------------------------------------------ | Note | ----- | - dynamic statistics used: dynamic sampling (level=2) |
---|
create private temporary table ORA$PTT_MY_TT2
on commit preserve definition as
select * from all_objects
Table created.
commit
Statement processed.
select count(*) from ORA$PTT_MY_TT2
COUNT(*) | 56830 |
---|
delete plan_table
3 row(s) deleted.
explain plan for select count(*) from ORA$PTT_MY_TT2
Statement processed.
select * from dbms_xplan.display()
PLAN_TABLE_OUTPUT | Plan hash value: 3727903318 | ------------------------------------------------------------------------------------- | | Id | Operation | Name | Rows | Cost (%CPU)| Time | | ------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | 310 (1)| 00:00:01 | | | 1 | SORT AGGREGATE | | 1 | | | | | 2 | TABLE ACCESS STORAGE FULL| ORA$PTT_MY_TT2 | 56830 | 310 (1)| 00:00:01 | | ------------------------------------------------------------------------------------- | Note | ----- | - Global temporary table session private statistics used |
---|
truncate table ORA$PTT_MY_TT2 drop storage
Table dropped.
insert /*+ APPEND */ into ORA$PTT_MY_TT2
select * from all_objects
where rownum <= 1000
1000 row(s) inserted.
commit
Statement processed.
select count(owner) from ORA$PTT_MY_TT2
COUNT(OWNER) | 1000 |
---|
delete plan_table
3 row(s) deleted.
explain plan for select count(owner) from ORA$PTT_MY_TT2
Statement processed.
select * from dbms_xplan.display()
PLAN_TABLE_OUTPUT | Plan hash value: 3727903318 | --------------------------------------------------------------------------------------------- | | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | | --------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | 66 | 6 (0)| 00:00:01 | | | 1 | SORT AGGREGATE | | 1 | 66 | | | | | 2 | TABLE ACCESS STORAGE FULL| ORA$PTT_MY_TT2 | 1000 | 66000 | 6 (0)| 00:00:01 | | --------------------------------------------------------------------------------------------- | Note | ----- | - dynamic statistics used: dynamic sampling (level=2) |
---|
create private temporary table ORA$PTT_MY_TT3 ( x int, y int, z int )
on commit preserve definition
Table created.
insert /*+ APPEND */ into ORA$PTT_MY_TT3
select rownum, rownum, rownum from dual
connect by level <= 50000
50000 row(s) inserted.
commit
Statement processed.
select count(z) from ORA$PTT_MY_TT3
COUNT(Z) | 50000 |
---|
delete plan_table
3 row(s) deleted.
explain plan for select count(z) from ORA$PTT_MY_TT3
Statement processed.
select * from dbms_xplan.display()
PLAN_TABLE_OUTPUT | Plan hash value: 253260165 | --------------------------------------------------------------------------------------------- | | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | | --------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | 13 | 38 (0)| 00:00:01 | | | 1 | SORT AGGREGATE | | 1 | 13 | | | | | 2 | TABLE ACCESS STORAGE FULL| ORA$PTT_MY_TT3 | 56208 | 713K| 38 (0)| 00:00:01 | | --------------------------------------------------------------------------------------------- | Note | ----- | - dynamic statistics used: dynamic sampling (level=2) |
---|
delete plan_table
3 row(s) deleted.
explain plan for insert /*+ APPEND */ into ORA$PTT_MY_TT3
select rownum, rownum, rownum from dual
connect by level <= 50000
0 row(s) inserted.
select * from dbms_xplan.display()
PLAN_TABLE_OUTPUT | Plan hash value: 1600317434 | ----------------------------------------------------------------------------------------- | | Id | Operation | Name | Rows | Cost (%CPU)| Time | | ----------------------------------------------------------------------------------------- | | 0 | INSERT STATEMENT | | 1 | 2 (0)| 00:00:01 | | | 1 | LOAD AS SELECT | ORA$PTT_MY_TT3 | | | | | | 2 | COUNT | | | | | | |* 3 | CONNECT BY WITHOUT FILTERING| | | | | | | 4 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | | ----------------------------------------------------------------------------------------- | Predicate Information (identified by operation id): | --------------------------------------------------- | 3 - filter(LEVEL<=50000) |
---|