简单模拟错误的过程如下:
SQL> truncate table test1;
Table truncated.
SQL> insert into test1 select * from dba_objects;
49749 rows created.
SQL> commit;
Commit complete.
SQL> insert into test1 select * from test1;
49749 rows created.
SQL> /
99498 rows created.
SQL> /
198996 rows created.
SQL> commit;
Commit complete.
SQL>
SQL>
SQL> insert into test1 select * from test1;
397992 rows created.
SQL> /
795984 rows created.
SQL> commit;
Commit complete.
SQL>
SQL> select count(*) from test1;
COUNT(*)
----------
1591968
SQL> insert into test1 select * from test1;
1591968 rows created.
SQL> commit;
Commit complete.
SQL> insert into test1 select * from test1;
insert into test1 select * from test1;
*
ERROR at line 1:
ORA-01653: unable to extend table DBSEEK.TEST1 by 1024 in tablespace TBS1652
ORA-06512: at line 3
SQL> alter database datafile '/oracle/oradata/orcl/tbs1652_01.dbf' resize 800M;
Database altered.
SQL> alter table test1 move;
alter table test1 move
*
ERROR at line 1:
ORA-01652: unable to extend temp segment by 1024 in tablespace TBS1652
SQL> CREATE INDEX idx_test1_id ON test1(owner,object_id) tablespace tbs1652;
CREATE INDEX idx_test1_id ON test1(owner,object_id) tablespace tbs1652
*
ERROR at line 1:
ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
再开一个session 来检查当前的临时表空间
此时临时表空间里面运行的会话信息:
USERNAME SID SERIAL# OSUSER TABLESPACE BLOCKS
---------- ---------- ---------- --------------- ---------- ----------
SQL_TEXT
----------------------------------------------------------------------
DBSEEK 159 5 oracle TEMP 6656
CREATE INDEX idx_test1_id ON test1(owner,object_id) tablespace tbs1652
临时段的使用情况
TABLESPACE TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS
---------- ------------ ----------- -----------
TEMP 11904 11904 0
SQL> alter database tempfile '/oracle/oradata/orcl/temp01.dbf' resize 200M;
Database altered.
SQL> CREATE INDEX idx_test1_id ON test1(owner,object_id) tablespace tbs1652;
Index created.
总结:
1.使用临时段的操作:
排序操作 比如select或dml(ddl)语句中包含order by之类;
create index
create pk constraint (其实这个跟create index类似,因为创建主键约束时默认会同时创建index)
enable constraint操作
create table语句
bitmap index
hash join
2.ORA-1652的解决方法:
解决方法是,1加大临时表空间,2是找到临时表空间使用过大的原因,优化SQL语句,尽量降低排序操作
============================================================================================
-- The End --