欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

关于oracle数据库误删表空间文件后无法登陆sqlplus问题的解决方法

程序员文章站 2022-08-20 14:46:30
背景: 今天学习了oracle表空间的创建,于是兴冲冲的跑去创建了两个表空间,文件名分别是是/u01/test/my_01.dbf和/u01/test/my_02.dbf。软件:centos-6.7...

背景: 今天学习了oracle表空间的创建,于是兴冲冲的跑去创建了两个表空间,文件名分别是是/u01/test/my_01.dbf和/u01/test/my_02.dbf。软件:centos-6.7-x86_64,linux.x64_11gr2_database。创建命令如下:

create tablespace my_01 logging datafile '/u01/test/my_01.dbf' size 128m

alter tablespace my_01 add datafile '/u01/test/my_01.dbf' size 128m

看着/u01/test/下生成两个表空间文件,欣喜若狂。毕竟是自己创造的。然后,我嫌这两个表空间文件占空间,于是在centos图形界面将其move to trash,效果如下:

当我再次使用sqlplus命令时,发现如下错误:

当看到'/u01/test/my_01.dbf'我就想:莫非跟我删除表空间文件有关吧。。。既然问题来了,就要上网找资料,毕竟rp爆发,找到了原因:在oracle启动后,用户登录时是要将方案中原有的配置信息装载进入,装载过程中有文件未找到,所以就报出错误。感谢这位网友的倾情奉献 https://www.doc88.com/p-634723326544.html

解决过程:

[oracle@jie ~]$ sqlplus /nolog

sql*plus: release 11.2.0.1.0 production on mon feb 29 16:05:31 2016

copyright (c) 1982, 2009, oracle. all rights reserved.

sql> conn /as sysdba

connected to an idle instance.

sql> startup

oracle instance started.

total system global area 830930944 bytes

fixed size 2217912 bytes

variable size 507512904 bytes

database buffers 318767104 bytes

redo buffers 2433024 bytes

database mounted.

ora-01157: cannot identify/lock data file 6 - see dbwr trace file --错误信息

ora-01110: data file 6: '/u01/test/my_01.dbf'

sql> alter database datafile 6 offline drop; --这里的6是根据上面错误信息里的data file 6

database altered.

sql> alter database open resetlogs;

alter database open resetlogs

*

error at line 1:

ora-01139: resetlogs option only valid after an incomplete database recovery

sql> alter database open;

alter database open

*

error at line 1:

ora-01157: cannot identify/lock data file 7 - see dbwr trace file

ora-01110: data file 7: '/u01/test/my_02.dbf'

(因为我有误删了两个表空间文件,所以还有个7要处理,重复上面步骤)

sql> alter database datafile 7 offline drop;

database altered.

sql> alter database open resetlogs;

alter database open resetlogs

*

error at line 1:

ora-01139: resetlogs option only valid after an incomplete database recovery

sql> alter database open;

database altered.

sql> shutdown normal

database closed.

database dismounted.

oracle instance shut down.

sql> startup mount;

oracle instance started.

total system global area 830930944 bytes

fixed size 2217912 bytes

variable size 507512904 bytes

database buffers 318767104 bytes

redo buffers 2433024 bytes

database mounted.

sql> conn scott

enter password:

error:

ora-01033: oracle initialization or shutdown in progress

process id: 0

session id: 0 serial number: 0

warning: you are no longer connected to oracle.

(重新启动下oracle就好!)

sql> quit

[oracle@jie ~]$ su - oracle

password:

[oracle@jie ~]$ sqlplus /nolog

sql*plus: release 11.2.0.1.0 production on mon feb 29 16:44:51 2016

copyright (c) 1982, 2009, oracle. all rights reserved.

sql> conn /as sysdba

connected.

sql> startup

ora-01081: cannot start already-running oracle - shut it down first

sql> shutdown immediate

ora-01109: database not open

database dismounted.

oracle instance shut down.

sql> startup

oracle instance started.

total system global area 830930944 bytes

fixed size 2217912 bytes

variable size 507512904 bytes

database buffers 318767104 bytes

redo buffers 2433024 bytes

database mounted.

database opened.

sql> conn scott

enter password:

connected.

至此,问题解决!!