ORACLE常见错误代码的分析与解决


在使用ORACLE的过程过,我们会经常遇到一些ORACLE产生的错误,对于初学者而言,这些错误可能有点模糊,而且可

能一时不知怎么去处理产生的这些错误,本人就使用中出现比较频繁的错误代码一一做出分析,希望能够帮助你找到一个

合理解决这些错误的方法,同时也希望你能够提出你的不同看法。毕竟作为一种交流的手段,个人意见难免过于偏颇,而

且也必定存在着不足,出错之处在所难免。写这篇文章的目的就是想通过相互之间的交流共同促进,共同进步。

ORA-01650:unable to extend rollback segment NAME by NUM intablespace NAME

产生原因:上述ORACLE错误为回滚段表空间不足引起的,这也是ORACLE数据管理员最常见的ORACLE错误信息。当用户

在做一个非常庞大的数据操作导致现有回滚段的不足,使可分配用的回滚段表空间已满,无法再进行分配,就会出现上述

的错误。

解决方式:使用“ALTER TABLESPACE tablespace_name ADD DATAFILE filename SIZE size_of_file”命令向指定的

数据增加表空间,根据具体的情况可以增加一个或多个表空间。当然这与还与你主机上的裸盘设备有关,如果你主机的裸

盘设备已经没有多余的使用空间,建议你不要轻意的增加回滚段表空间的大小,可使用下列的语句先查询一下剩余的

tablespace空间有多少:

Select user_name,sql_text from V$open_cursor where user_name=’

  1<user_name>; 
  2
  3如果多余的空间比较多,就可以适当追加一个大的回滚段给表空间使用,从而避免上述的错误。你也可以用以下语句 
  4
  5来检测一下rollback segment的竞争状况: 
  6
  7Select class,count from V$waitstat where calss in(system undo header,system undo block,undo 
  8
  9header,undo block); 
 10
 11Select sum(value) from V$sysstat where name in (db_block_gets,consistents gets); 
 12
 13如果任何一个class in count/sum(value)大于1%,就应该考虑增加rollback segment 
 14
 15相应的英文如下: 
 16
 17Cause:Failed to allocate extent from the rollback segment in tablespace 
 18
 19Action:Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the specified 
 20
 21tablespace. 
 22
 23ORA-01652:unable to extend temp segment by num in tablespace name 
 24
 25产生原因:ORACLE临时段表空间不足,因为ORACLE总是尽量分配连续空间,一但没有足够的可分配空间或者分配不连 
 26
 27续就会出现上述的现象。 
 28
 29解决方法:我们知道由于ORACLE将表空间作为逻辑结构-单元,而表空间的物理结构是数据文件,数据文件在磁盘上物 
 30
 31理地创建,表空间的所有对象也存在于磁盘上,为了给表空间增加空间,就必须增加数据文件。先查看一下指定表空间的 
 32
 33可用空间,使用视图SYS.DBA_FREE_SPACE,视图中每条记录代表可用空间的碎片大小: 
 34
 35SQL&gt;Select file_id,block_id,blocks,bytes from sys.dba_free_space where tablespace_name=<users>; 
 36
 37返回的信息可初步确定可用空间的最大块,看一下它是否小于错误信息中提到的尺寸,再查看一下缺省的表空间参 
 38
 39数: 
 40
 41SQL&gt;SELECT INITIAL_EXTENT,NEXT_EXTENT,MIN_EXTENTS,PCT_INCREASE FROM SYS.DBA_TABLESPACES WHERE 
 42
 43TABLESPACE_NAME=name; 
 44
 45通过下面的SQL命令修改临时段表空间的缺省存储值: 
 46
 47SQL&gt;ALTER TABLESPACE name DEFAULT STORAGE (INITIAL XXX NEXT YYY); 
 48
 49适当增大缺省值的大小有可能解决出现的错误问题,也可以通过修改用户的临时表空间大小来解决这个问题: 
 50
 51SQL&gt;ALTER USER username TEMPORARY TABLESPACE new_tablespace_name; 
 52
 53使用ALTER TABLESPACE命令,一但完成,所增加的空间就可使用,无需退出数据库或使表空间脱机,但要注意,一旦添加 
 54
 55了数据文件,就不能再删除它,若要删除,就要删除表空间。 
 56
 57一个报错例子如下: 
 58
 59ORA-1652:unable to extend temp segment by 207381 in tablespace TEMPSPACE 
 60
 61相应的英文如下: 
 62
 63Cause: Failed to allocate extent for temp segment in tablespace 
 64
 65Action:Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the specified 
 66
 67tablespace or create the object in another tablespace. 
 68
 69产生原因:当ORACLE访问一个数据块时,由于1、硬件的I/O错误;2、操作系统的I/O错误或缓冲问题;3、内存或paging 
 70
 71题;4、ORACLE试图访问一个未被格式化的系统块失败;5、数据文件部分溢出等上述几种情况的一种引起了逻辑坏块或者 
 72
 73物理坏块,这时就会报ORA-01578的错误。 
 74
 75解决方式:由于ORACLE只有在访问到有问题的数据文件时才会报错,所以报错的时间有可能会比实际出错的时间要晚,如 
 76
 77ORA-01578出错信息提示数据坏块指向的是用户自己的数据文件,则用以下方法来解决: 
 78
 79如果通过下面的SQL语句查出的坏块出现有索引上,则只需重建索引即可 
 80
 81SQL&gt;Select owner,segment_name,segment_type from dba_extents where file_id=<f> and <b> between block_id and 
 82
 83block_id+blocks-1;(<f><b>分别是ORA-01578报出的坏块出现的文件号和块号) 
 84
 85如果坏块出现在表上,先用以下语句分析是否为永久性坏块(建议多执行一两次,有助于鉴别数据坏块是永久性的(硬盘 
 86
 87上的物理坏块)还是随机性的(内存或硬件错误引起)): 
 88
 89SQL&gt;Analyze table <table_name> validate structure cascade; 
 90
 91执行该命令后,可能会出现以下的结果: 
 92
 93ORA-01578:与原先错误信息有相同的参数,为永久性的物理或逻辑坏块;与原先错误信息有不同的参数,可能与内存, 
 94
 95page spaceI/O设备有关。 
 96
 97如果用户有此表的最新备份,那么最好是用此备份来恢复此表,或者使用event 10231来取出坏块以外的数据: 
 98
 99&lt;1&gt;.先关闭数据库 
100
101&lt;2&gt;.编辑init<sid>.ora文件,加入: 
102
103event=”10231 trace name context forever,level 10” 
104
105&lt;3&gt;.startup restrict 
106
107&lt;4&gt;.创建一个临时表:SQL&gt;create table errortemp as select * from error;(error是坏表的表名) 
108
109&lt;5&gt;.eventinit<sid>.ora文件中删掉并重起数据库 
110
111&lt;6&gt;.rename坏表,把临时表rename成坏表的表名 
112
113&lt;7&gt;.创建表上的INDEX 
114
115如果ORA-01578出错信息提示数据坏块指向的是数据字典或者是回滚段的话,你应该立即与ORACLE公司联系,共同商量一个 
116
117好的解决办法。 
118
119这里所讲的解决方法只是比较常见的一种,一些更为具体的解决办法可以查看一下ORACLE的故障解决手册,那里面有浞及 
120
121使用ROWID方法来取出坏块以外的数据的方法,这里就不介绍了。 
122
123相应的英文如下: 
124
125Cause:The given data block was corrupted,probably due to program errors 
126
127Action:Try to restore the segment containing the given data block,This may involve dropping the segment 
128
129and recreating it,If there is a trace file,report the messages recorded in it to customer support. 
130
131ORA-01628:max # of extents num reached for rollback segment num 
132
133产生原因:这种错误通常为一个回滚段和一个表空间已经达到MAXEXTENTS参数设置的极限。要注意的是这个MAXEXTENTS 
134
135是该回滚段或表空间的硬件极限,硬件极限取决于数据库创建时在init.ora文件中指定的DB_BLOCK_SIZE参数的值。 
136
137解决方法:使用SQL命令ALTER TABLESPACESTORAGEMAXEXTENTS XXXX)来增加 MAXEXTENTS,其中“XXXX”值必须大于 
138
139错误信息中所指的数值,但不能大于LARGEST MAXEXTENT的值,如果已经达到了LARGEST MAXEXTENT VALUE,解决的办法就 
140
141是重新创建较大的范围尺寸,使用带有选项COMPRESS=YExport工具导出表,如果表空间有可用空间,先给表做一个备 
142
143份,用alter tablespace tablespace_name更改其名字,然后再装载表回数据库。 
144
145查看其错误出现的地方,如果出现在回滚段或索引上,那么必须将其删除并重建,如果出现在临时表空间,修改临时表空 
146
147间的存储字段,便可解决这个问题。 
148
149一个报错例子如下: 
150
151ORA-1628:max # extents 50 reached for rollback segment RBS_1 
152
153相应的英文如下: 
154
155Cause: An attempt was made to extend a rollback segment that already has reached its maximum size or space 
156
157could not be allocated in the data dictionary to contain the definition of the object. 
158
159Action:If possible,increase the value of either the MAXEXTENTS or PCTINCREASE initialization parameters or 
160
161find the data dictionary table lacking space and alter the storage parameters,as described in the Oracle8 
162
163Server Administrators Guide. 
164
165产生原因:这种错误通常为ORACLE的内部错误,只对OSSORACLE开发有用。ORA-600的错误经常伴随跟踪文件的状态转储 
166
167(系统状态和进程状态),系统状态存储将包括ORACLE RDBMS持有的当前对象的信息,进程状态转储则将显示特殊进程持 
168
169有的对象,当进程符合了某错误条件时,经常是由于一些信息取自它持有的一个块,如果我们知道这些错误进程持有的 
170
171块,就容易跟踪问题的来源。 
172
173解决方法:一般来说出现这个错误我们本身是无法解决的,只有从提高系统本身各方面来解决这个内部问题,如增加硬件 
174
175设备,调整系统性能,使用OPS(当然OPS从某种意义上说并不是一种好的解决方式)等。ORA-600错误的第一个变量用于标 
176
177记代码中错误的位置(代码中的每个部分的第一变量都不一样),从第二个到第五个变量显示附加信息,告诉OSS代码在哪 
178
179里出现了错误。 
180
181一个报错例子如下: 
182
183ORA-00600: internal error code, arguments: [1237], [], [], [], [], [], [], [] 
184
185相应的英文如下: 
186
187Cause:This is a catchall internal error message for Oracle program exceptions.It indicates that a process 
188
189has met a low-level,unexpected condition.Various causes of this message include: 
190
191Time-outs(超时) 
192
193File corruption(文件太老) 
194
195Failed data checks in memory(内存检索失败) 
196
197Hardware,memory,or I/O errors(硬件、内存或者磁盘错误) 
198
199Incorrectly restored files(错误的重建文件) 
200
201ORA-03113:end-of-file on communication channel 
202
203产生原因:通讯不正常结束,从而导致通讯通道终止 
204
205解决方法:1&gt;.检查是否有服进程不正常死机,可从alert.log得知 
206
2072&gt;.检查sql*Net Driver是否连接到ORACLE可执行程序 
208
2093&gt;.检查服务器网络是否正常,如网络不通或不稳定等 
210
2114&gt;.检查同一个网上是否有两个同样名字的节点 
212
2135&gt;.检查同一个网上是否有重复的IP地址 
214
215相应的英文如下: 
216
217Cause:An unexpected end-of-file was processed on the communication channel.The problem could not be 
218
219handled by the Net8,two task,software.This message could occur if the shadow two-task process associated 
220
221with a Net8 connect has terminated abnormally,or if there is a physical failure of the interprocess 
222
223communication vehicle,that is,the network or server machine went down. 
224
225Action:If this message occurs during a commection attempt,check the setup files for the appropriate Net8 
226
227driver and confirm Net8 software is correctly installed on the server.If the message occurs after a 
228
229connection is well established,and the error is not due to a physical failure,check if a trace file was 
230
231generated on the server at failure time.Existence of a trace file may suggest an Oracle internal error 
232
233that requires the assistance of customer support. 
234
235ORA-00942:table or view does not exist 
236
237产生原因:这是由于装载的表或视图不存在,多半是CATEXP.SQL还没有运行,无法执行Export视图,如果CATEXP.SQL已经运 
238
239行,则可能是版本错误。 
240
241解决方法:因为ImportExport共享的一些视图是通过运行CATEXP.SQL来装载的(它们具有相同的视图),并不生成单独 
242
243CATEXP.SQL,因而造成视图与Export代码不同步,较难保持彼此之间的兼容,用户就必须建立自己的Export应用,从而 
244
245避免ORA-00942的错误。 
246
247相应的英文如下: 
248
249Cause:The table or view entered does not exist,a synonym that is jnot allowed here was used,or a view was 
250
251referenced where a table is required.Existing user tables and views can be listed by querying the data 
252
253dictionary.Certain privileges may required to access the table.If an application returned this message,the 
254
255table the application tried to access does not exist in the database,or the application does not have 
256
257access to it. 
258
259Action:Check each of the following: 
260
261The spelling of the table or view name. 
262
263That a view is not specified where a table is required 
264
265That an existing table or view name exists. 
266
267Contact the database administrator if the table needs to be created or if user or application priviledes 
268
269are required to access the table. 
270
271Also, if attempting to access a table or view in another schema,make certain thecorrect schema is 
272
273referenced and that access to the object is granted. 
274
275ORA-01598:rollback segment name is not online 
276
277Cause:The rollback segment was taken offline either manually or by SMON. 
278
279Action:Check the status of the rollback segment in DBA_ROLLBACK_SEGS. 
280
281ORA-1636: rollback segment name is already online 
282
283Cause:A rollback segment can only be used by one instance and an instance is trying to bring a rollback 
284
285segment online that is already in use. 
286
287Action:Check that the values set in the initialization parameter file for parameters 
288
289ROLLBACK_SEGMENTS,ROLLBACK_SEGMENT_INITIAL,and ROLLBACK_SEGMENT_COUNT are correctly set for the instance 
290
291whiththe problem,Also check that the instance is using the correct initialization parameter file.Make sure 
292
293you are not confused about the difference between private and public rollback segments.See the Oracle8 
294
295Server Administrators Guide for more information about using rollback segments in paraller mode. 
296
297上述错误均为我们在使用回滚段时比较常见的问题,ORA-01598指明当前使用的回滚段的状态为“not online”,不能使 
298
299用,将它改为“online”状态即可使用;ORA-01636指明当前回滚段已经为“online”状态,可以直接使用,不用再集合 
300
301它。 
302
303ORA-1636 signalled during: alter rollback segment rb00 online 
304
305我们在做统计时还可能遇到下述问题:一个rollback segment的状态为”Needs Recovery”的现象,这是由于ORACLE回退 
306
307一个事物表中的没有提交的事物时失败所造成的。通常原因为一个datafile或者tablespace是在offline的状态或者一个 
308
309undo的目标被破坏或者rollback segment被破坏。解决的办法是将所有的tablespacedatafile都置为online状态,如果 
310
311不能解决则做下面的工作:1&gt;.initsid.ora中加入event=”10015 trace name context forever lever 
312
31310”;2&gt;.shutdown数据库然后重启;3&gt;.在$ORACLE_HOME/rdbms/log下,找到startup时生成的trace file;4&gt;.trace文件 
314
315中,找到下列信息“error recovery tx(#,#) object #”;5&gt;.根据object#(sys.dba_objects表中的object_id相同) 
316
317sys.dba_objects表中查出该object的名字;6&gt;.将该object drop;7&gt;.init.ora文件中将该rollback segment放回 
318
319rollback_segments参数中,删除event;8&gt;.shutdown数据库然后重启。此时”Needs Recovery”的问题应该是完全解决 
320
321了,否则就是rollback segment被破坏了。 
322
323ORA-01688:unable to extend table name.name partition NAME by NUM in tablespace NAME 
324
325产生原因:指定的tablespace空间已经被占用满,无法扩展。 
326
327解决方法:使用“ALTER TABLESPACE ADD DATAFILE”命令增加文件系统文件和原始分区,或者增加INITIAL的大小(如: 
328
329alter tablespace CDRS101 default storage(next 500M pctincrease 1))应该能够解决,否则就是有人使用你的表空间 
330
331上创建了一个比较大的数据文件导致你的表空间不够用。 
332
333一个报错例子如下: 
334
335ORA-1688: unable to extend table RMMCDR.LOCAL_CDR partition LOCAL_CDR101 by 460800 in tablespace CDRS101 
336
337相应的英文如下: 
338
339Cause:An extent could not be allocated for a table segment in tablespace 
340
341Action:Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace</sid></sid></table_name></b></f></b></f></users></user_name>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus