热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

从tablespace中删除空的datafile时报ORA-03262

我看了一下这个文章,不能删除的原因是Oraclesoftware的bug,也就是程序的bug。想要drop掉的datafile的relativefileno与别

我看了一下这个文章,不能删除的原因是Oracle software的bug,也就是程序的bug。想要drop掉的datafile的 relative file no 与 别

参考自:

Cannot Drop Empty Datafile From Tablespace ORA-03262 (文档 ID 1353029.1)

适用于:

Oracle Server - Enterprise Edition - Version: 11.2.0.2 and later [Release: 11.2 and later ]
Information in this document applies to any platform.

症状:

ALTER TABLESPACE ... DROP DATAFILE fails consistently with ORA-3262 'the file
is non-empty', even if there are no segments (including temporary and recycle bin) in the datafile.

测试用例:

TESTCASE
~~~~~~~~

drop tablespace test1_ts including contents and datafiles;

drop tablespace test2_ts including contents and datafiles;

create tablespace test1_ts
datafile '/oracle/oradata/d1v11202/test1_1_ts.dbf' size 10M autoextend on maxsize unlimited,
'/oracle/oradata/d1v11202/test1_2_ts.dbf' size 10M autoextend on maxsize unlimited;

create tablespace test2_ts
datafile '/oracle/oradata/d1v11202/test2_1_ts.dbf' size 10M autoextend on maxsize unlimited,
'/oracle/oradata/d1v11202/test2_2_ts.dbf' size 10M autoextend on maxsize unlimited;

/*
SQL> select file#, relfile#, ts# from file$;

FILE# RELFILE# TS#
---------- ---------- ----------
1 1 0
2 2 1
3 3 2
4 4 4
5 5 5
6 6 6
7 7 8
8 8 9
9 9 10
10 10 11
11 11 13

FILE# RELFILE# TS#
---------- ---------- ----------
12 12 14
13 13 14
14 14 15
15 15 15

15 rows selected.
*/

drop tablespace test1_ts including contents;

drop tablespace test2_ts including contents;

host rm /oracle/oradata/d1v11202/test1_1_ts.dbf

host rm /oracle/oradata/d1v11202/test1_2_ts.dbf

host rm /oracle/oradata/d1v11202/test2_1_ts.dbf

host rm /oracle/oradata/d1v11202/test2_2_ts.dbf

/*to duplicate the rfile# */
alter session set events '10120 trace name context forever';

create tablespace test1_ts
datafile '/oracle/oradata/d1v11202/test1_1_ts.dbf' size 10M autoextend on maxsize unlimited,
'/oracle/oradata/d1v11202/test1_2_ts.dbf' size 10M autoextend on maxsize unlimited;

conn / as sysdba

create tablespace test2_ts
datafile '/oracle/oradata/d1v11202/test2_1_ts.dbf' size 10M autoextend on maxsize unlimited,
'/oracle/oradata/d1v11202/test2_2_ts.dbf' size 10M autoextend on maxsize unlimited;

/*Next steps need to be adapted to your results*/

SQL> select file#, relfile#, ts# from file$;

FILE# RELFILE# TS#
---------- ---------- ----------
1 1 0
2 2 1
3 3 2
4 4 4
5 5 5
6 6 6
7 7 8
8 8 9
9 9 10
10 10 11
11 11 13

FILE# RELFILE# TS#
---------- ---------- ----------
12 13 14
13 14 14
14 14 15
15 15 15

15 rows selected.

/*TS# 14 and 15 each have 2 datafiles:(12, 13) and (14,15) with a common rfile# 14 for file#(13,14).
You need to see in which ts# the file with rfile# 14 (duplicate) is the first - meaning it cannot be dropped.
Drop file# 15 - drop the datafile from the tablespace where rfile# 14 is the first databafile.
Create a segment in this tablespace which has only 1 datafile left.
Try to drop after that the dtaafile from the first tablespace (where it is the second datafile), which is empty.
In this case, it would be file# 13 which has the same rfile# 14 as file#14, which is not empty.
*/

SQL> alter tablespace test2_ts drop datafile 15;

Tablespace altered.

SQL> create table test_drop tablespace test2_ts as select * from dual;

Table created.

SQL> select file#, type#, ts#, block# from seg$ where file# = 14 and type# != 3;

FILE# TYPE# TS# BLOCK#
---------- ---------- ---------- ----------
14 5 15 130

SQL> alter tablespace test1_ts drop datafile 13;
alter tablespace test1_ts drop datafile 13
*
ERROR at line 1:
ORA-03262: the file is non-empty

我看了一下这个文章,不能删除的原因是Oracle software的bug,也就是程序的bug。

想要drop掉的datafile的 relative file no 与 别的tablespace中的 其他datafile的 relative file no 相重复。

'alter tablespace ... drop datafile ...' 检查 rfile# 而不是 absolute file objects (file#)。
有相同rfile#的其他datafile 属于不同的tablespace, 并且,不为空。
The issue has been investigated in Bug 12735162: CANNOT DROP EMPTY DATAFILE FROM TABLESPACES WITH DUPLICATED RELATIVE FILE NO

解决方法:

该bug在12.1中被解决(fix).There is also a request to include the fix in 11.2.0.3 currently being worked. ---这句话是不是在11.2.0.3中有单独的patch 能解决这个问题?

1. 变通方法是: 从empty datafile所在的表空间中move掉所有的对象,然后 drop the tablespace including contents and datafiles.

2. 为了fix 这个问题,请检查针对的你的release是否有patch,否则,,请向Oracle Support 提交一个sr 来要求一个patch。


推荐阅读
  • 推荐一个ASP的内容管理框架(ASP Nuke)的优势和适用场景
    本文推荐了一个ASP的内容管理框架ASP Nuke,并介绍了其主要功能和特点。ASP Nuke支持文章新闻管理、投票、论坛等主要内容,并可以自定义模块。最新版本为0.8,虽然目前仍处于Alpha状态,但作者表示会继续更新完善。文章还分析了使用ASP的原因,包括ASP相对较小、易于部署和较简单等优势,适用于建立门户、网站的组织和小公司等场景。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了使用postman进行接口测试的方法,以测试用户管理模块为例。首先需要下载并安装postman,然后创建基本的请求并填写用户名密码进行登录测试。接下来可以进行用户查询和新增的测试。在新增时,可以进行异常测试,包括用户名超长和输入特殊字符的情况。通过测试发现后台没有对参数长度和特殊字符进行检查和过滤。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文由编程笔记小编整理,介绍了PHP中的MySQL函数库及其常用函数,包括mysql_connect、mysql_error、mysql_select_db、mysql_query、mysql_affected_row、mysql_close等。希望对读者有一定的参考价值。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • MyBatis错题分析解析及注意事项
    本文对MyBatis的错题进行了分析和解析,同时介绍了使用MyBatis时需要注意的一些事项,如resultMap的使用、SqlSession和SqlSessionFactory的获取方式、动态SQL中的else元素和when元素的使用、resource属性和url属性的配置方式、typeAliases的使用方法等。同时还指出了在属性名与查询字段名不一致时需要使用resultMap进行结果映射,而不能使用resultType。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
author-avatar
高小原gy_941
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有