澄清大家一个常见的错误:临时表是否产生redo
临时表本身的操作并不产生redo,但是在临时表中处理数据时,是要产生undo的,而undo是要产生redo的,但相比较普通表要少很多。
[oracle@mydb02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 7 14:21:52 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
startup
Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 818401280 bytes
Fixed Size 2257680 bytes
Variable Size 532679920 bytes
Database Buffers 281018368 bytes
Redo Buffers 2445312 bytes
Database mounted.
Database opened.
SQL> create table t1(id number) tablespace users;
Table created.
SQL> set pagesize 1200
SQL> set linesize 1200
SQL> set autotrace trace stat
SQL> insert into t1 select obj# from obj$;
87046 rows created.
Statistics
----------------------------------------------------------
99 recursive calls
2247 db block gets
1431 consistent gets
193 physical reads
1398988 redo size
838 bytes sent via SQL*Net to client
788 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
8 sorts (memory)
0 sorts (disk)
87046 rows processed
SQL> create global temporary table t2 (id number) ;
Table created.
SQL> insert into t2 select obj# from obj$;
87047 rows created.
Statistics
----------------------------------------------------------
4 recursive calls
1010 db block gets
385 consistent gets
0 physical reads
241176 redo size
838 bytes sent via SQL*Net to client
788 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
87047 rows processed
临时表本身的操作并不产生redo,但是在临时表中处理数据时,是要产生undo的,而undo是要产生redo的,但相比较普通表要少很多。
[oracle@mydb02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 7 14:21:52 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
startup
Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 818401280 bytes
Fixed Size 2257680 bytes
Variable Size 532679920 bytes
Database Buffers 281018368 bytes
Redo Buffers 2445312 bytes
Database mounted.
Database opened.
SQL> create table t1(id number) tablespace users;
Table created.
SQL> set pagesize 1200
SQL> set linesize 1200
SQL> set autotrace trace stat
SQL> insert into t1 select obj# from obj$;
87046 rows created.
Statistics
----------------------------------------------------------
99 recursive calls
2247 db block gets
1431 consistent gets
193 physical reads
1398988 redo size
838 bytes sent via SQL*Net to client
788 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
8 sorts (memory)
0 sorts (disk)
87046 rows processed
SQL> create global temporary table t2 (id number) ;
Table created.
SQL> insert into t2 select obj# from obj$;
87047 rows created.
Statistics
----------------------------------------------------------
4 recursive calls
1010 db block gets
385 consistent gets
0 physical reads
241176 redo size
838 bytes sent via SQL*Net to client
788 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
87047 rows processed