学习索引的相关知识,建立索引时报错:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> create index idx_test on tab_test(object_id) tablespace test;
create index idx_test on tab_test(object_id) tablespace test
                         *
第 1 行出现错误:
ORA-25153: 临时表空间为空

查看alter :

*********************************************************************
WARNING: The following temporary tablespaces contain no files.
         This condition can occur when a backup controlfile has
         been restored.  It may be necessary to add files to these
         tablespaces.  That can be done using the SQL statement:
 
         ALTER TABLESPACE <tablespace_name> ADD TEMPFILE
 
         Alternatively, if these temporary tablespaces are no longer
         needed, then they can be dropped.
           Empty temporary tablespace: TEMP  ----无数据文件
*********************************************************************

查看表空间:

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
UNDOTBS1                       ONLINE
SYSAUX                         ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
GHOST                          ONLINE
TEST                           ONLINE
HUNT                           ONLINE

SQL> select tablespace_name,file_name from dba_temp_files;

未选定行

增加数据文件:

SQL> alter tablespace temp add tempfile 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\HUNT\T
EMP02.dbf' size 21M autoextend off;

表空间已更改。

SQL> create index idx_test on tab_test(object_id) tablespace ghost;
create index idx_test on tab_test(object_id) tablespace ghost
                         *
第 1 行出现错误:
ORA-01652: 无法通过 128 (在表空间 TEMP 中) 扩展 temp 段

SQL> alter database tempfile 'E:\oracle\product\10.2.0\oradata\hunt\TEMP02.DBF'
autoextend on next 100M;

数据库已更改。

---此处如果误用了alter database datafile 则报 ORA-01516: 不存在的日志文件, 数据文件或临时文件 的错。

SQL> create index idx_test on tab_test(object_id) tablespace ghost;

索引已创建。


SQL> commit;

 提交完成。