测试服务器:11.2.0.1
测试客户端:10.2.0.1 sqlplus
现象:建表之后,初始不会分配segment,造成dba_tables有表信息,而 dba_segments 没有信息。
SQL> create tablespace tbs
2 datafile 'tbs01.dbf'
3 size 1m;
表空间已创建。
SQL> create table cui (id number) tablespace tbs;
表已创建。
SQL> select table_name from user_tables where tablespace_name='TBS';
TABLE_NAME
------------------------------
CUI
SQL> select segment_name from user_SEGMENTS where tablespace_name='TBS';
未选定行
SQL> drop tablespace tbs ;
表空间已删除。
SQL> select table_name from user_tables where tablespace_name='TBS';
TABLE_NAME
------------------------------
CUI
SQL> select segment_name from user_SEGMENTS where tablespace_name='TBS';
未选定行
SQL>
SQL> select * from cui;
select * from cui
*
第 1 行出现错误:
ORA-00959: 表空间 'TBS' 不存在
SQL> create tablespace tbs
2 datafile 'tbs02.dbf'
3 size 1m;
表空间已创建。
SQL> select * from cui;
未选定行
SQL> /
未选定行
SQL> drop tablespace tbs;
表空间已删除。
SQL> select * from cui;
未选定行
SQL> select segment_name from user_SEGMENTS where tablespace_name='TBS';
未选定行
SQL> select table_name from user_tables where tablespace_name='TBS';
TABLE_NAME
------------------------------
CUI
SQL>
SQL> select count(*) from cui;
select count(*) from cui
*
第 1 行出现错误:
ORA-00959: 表空间 'TBS' 不存在
SQL> select * from cui;
未选定行
SQL> create tablespace tbs
2 datafile 'tbs04.dbf'
3 size 1m;
表空间已创建。
SQL> select * from cui;
未选定行
SQL> /
未选定行
SQL> drop tablespace tbs including contents;
表空间已删除。
SQL> select * from cui;
select * from cui
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
SQL>
SQL> select table_name from user_tables where tablespace_name='TBS';
未选定行
总结一:在删除表空间之前,如果执行过sql(例如:select * from x; 或者select count(*) from xx;等查询语句),那么在删除表空间之后,再次执行相同sql,则不会报错,当执行不同sql时,会报错,提示 表空间不存在。
SQL> create tablespace tbcui datafile 'tbcui01.dbf' size 1m;
表空间已创建。
SQL> create table tbcui_table(id number) tablespace tbcui;
表已创建。
SQL> select * from tbcui_table;
未选定行
SQL> drop tablespace tbcui;
表空间已删除。
SQL> select * from tbcui_table;
未选定行
SQL> /
未选定行
SQL> drop table tbcui_table;
drop table tbcui_table
*
第 1 行出现错误:
ORA-00959: 表空间 'TBCUI' 不存在
SQL> select table_name from user_tables where table_name='TBCUI_TABLE';
TABLE_NAME
------------------------------
TBCUI_TABLE
总结二:由于使用10.2.0.1sqlplus客户端测试,则命令drop tablespace xx;可以执行成功,从而造成垃圾字典信息TBCUI_TABLE,而如果用11.2.0.1sqlplus客户端测试的话,在命令drop tablespace xx时就会报错,提示加上including ,以避免造成垃圾字典信息。
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25093763/viewspace-1044404/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25093763/viewspace-1044404/