PL-SQL问题集锦

好像是在学习Oracle的时候在碰到的一些问题的解决方案收集,分享给大家,希望能对大家有用



1.ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源

Reason1:web服务器占用了表,关掉web就行了。谢谢各位。

Reason2:他人在用同一个表空间或在同一时间共同操作


2.FRM-40505: orACLE 无法查询

ToolTips:把菜单换为默认菜单。运行出现“FRM-40505 orACLE无法查询”时,选择Help->Display Error。你将看到出错的查询语句,和具体的Oracle错误号

这个错误经常出现在一些数据库项没有对应column的情况下

Solution:
1、block中有若干个item,而这些item的“DataBase Item”属性为Yes,但“Column Item”属性的值却为空,所以不能查询。
解决办法是:给这些item的“Column Name”属性指定Table/view中的Column
2、block中有非数据库字段,而这些item的“DataBase Item”属性为Yes。
解决方法:设置这些item的“DataBase Item”属性为No。


3.FRM-41839:在临时记录缓冲区文件/tmp/ztYpaa.tmp中磁盘的输入/输入错误

原因:是/TMP目录的空间用完了



解决办法:(从metalink上找的)

fact: oracle Application Object Library
symptom: FRM-41839: Disk I/O error on temporary record buffer file
/var/tmp/AAAJGaa9Z.TMP
symptom: Querying Values in a value set/Rows in row sets
change: NOTE ROLE: Also note that per Note 157385.1, this error occurs when
a query is performed which returns a large number of records. Forms is trying
to create a temporary file in which to place the results of the query. There
is not enough disk space on the drive which is assigned to TEMP/TMP. Either
free up more space or move the TEMP directory to a different drive.
cause: The /var/tmp referenced in the error message was on Web/Forms
tier.


fix:

There are 3 possible solutions:
1. Create a soft link to a mount point with more disk space
2. Add more disk space.
3. Set the TMPDIR environment variable and manually start the forms server. See
How to Change the Directory for the Forms Server Temporary File


4.FRM-10095: Assertion failed in iewbdbc_oracle_to_id

Cause:  An internal inconsistency was detected. Action:  Contact an oracle support representative, and proceed with caution.



Try to remove the timestamp datatype from the tables or make the block manually without using the wizard


数据表字段中含用timestamp类型的值,将timestamp类型改为date的值就OK了



5.PACKAGE BODY DEZAI.UBS_USER_ACTION 编译错误

错误:PLS-00428: 在此 Select 语句中缺少 INTO 子句
行:7
文本:select * from UBS_USer where USERID=DuserID;

Solution:在PL/SQL中,你应将Select 出来的结果放进一些变量或游标,你应将那个Select 放进一个游标,再利用游标循环显示出结果

在pl/sql中,selelct 的结果一定要用into 放在自定义的变量中


6.ORA-00942:表或视图不存在

select *
from all_objects
where object_type in ('TABLE','VIEW')
and object_name = 'mytest;
有这个表,而且owner也是我登陆的用户,怎么回事呀

select * from "mytest“

solution:估计是没有权限,用管理员帐号对此用户分配权限


7.ORA-01219: 数据库未打开: 仅允许在固定表/视图中查询

orA-01033:ORACLE   initialization   or   shutdown   in   progress
solution:

(1)运行语句:
Alter DATABASE OPEN
再运行语句
startup  mount;

在PL\SQL的SQL窗口中运行
sql>select group#,sequence#,archived,status from v$log;

得到结果
1    1    35    NO    INACTIVE
2    3    34    NO    INACTIVE
3    2    36    NO    CURRENT

sql>alter database clear logfile group 1;

sql>alter database clear logfile group 3;


在运行里执行:conn   internal/oracle   as   sysdba进行SQL模式  
  sql>shutdown   immediate  
  sql>startup   mount  
  sql>alter   database   open;  

    把以上这些步骤执行一下,看在哪里报错了,这就是手工启动数据库。  
    


8.动态执行表不可访问,本会话的自动统计被禁止"错误解决

    
grant select on v_$statname to thirdangle;
grant select on v_$sesstat to thirdangle;
grant select on v_$session to thirdangle;
grant select on v_$mystat to thirdangle;

thirdangle就是要被授权的用户名


9.FRM-40505: orACLE error: unable to perform query.

1、block中有若干个item,而这些item的“DataBase Item”属性为Yes,但“Column Item”属性的值却为空,所以不能查询。
解决办法是:给这些item的“Column Name”属性指定Table/view中的Column
2、block中有非数据库字段,而这些item的“DataBase Item”属性为Yes。
解决方法:设置这些item的“DataBase Item”属性为No。

10:ORA-00917:缺少逗号

insert into 语句中列的名字中不允许有空格;要是有空格,就会出现缺少逗号的错误

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='';

如果多余的空间比较多,就可以适当追加一个大的回滚段给表空间使用,从而避免上述的错误。你也可以用以下语句来检测一下rollback segment的竞争状况:

Select class, count

from V$waitstat

where calss in('system undo header', 'system undo block', 'undo header', 'undo block');




select sum(value)

from V$sysstat

where name in ('db_block_gets', 'consistents gets');


如果任何一个class in count/sum(value)大于1%,就应该考虑增加rollback segment。

相应的英文如下:

Cause: Failed to allocate extent from the rollback segment in tablespace.

Action: Use the Alter TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace.

11.ORA-01652: unable to extend temp segment by num in tablespace name.

产生原因:Oracle临时段表空间不足,因为Oracle总是尽量分配连续空间,一但没有足够的可分配空间或者分配不连续就会出现上述的现象。

解决方法:我们知道由于Oracle将表空间作为逻辑结构——单元,而表空间的物理结构是数据文件,数据文件在磁盘上物理地创建,表空间的所有对象也存在于磁盘上,为了给表空间增加空间,就必须增加数据文件。先查看一下指定表空间的可用空间,使用视图SYS.DBA_FREE_SPACE,视图中每条记录代表可用空间的碎片大小:

SQL>select file_id, block_id, blocks, bytes

    from sys.dba_free_space

    where tablespace_name='';


返回的信息可初步确定可用空间的最大块,看一下它是否小于错误信息中提到的尺寸,再查看一下缺省的表空间参数:

SQL>Select INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS, PCT_INCREASE

    FROM SYS.DBA_TABLESPACES

    Where TABLESPACE_NAME=name;


通过下面的SQL命令修改临时段表空间的缺省存储值:

SQL>Alter TABLESPACE name DEFAULT STORAGE (INITIAL XXX NEXT YYY);

适当增大缺省值的大小有可能解决出现的错误问题,也可以通过修改用户的临时表空间大小来解决这个问题:

SQL>Alter USER username TEMPORARY TABLESPACE new_tablespace_name;

使用Alter TABLESPACE命令,一但完成,所增加的空间就可使用,无需退出数据库或使表空间脱机,但要注意,一旦添加了数据文件,就不能再删除它,若要删除,就要删除表空间。

12.ORA-1652:unable to extend temp segment by 207381 in tablespace TEMPSPACE

相应的英文如下:

Cause: Failed to allocate extent for temp segment in tablespace

Action: Use the Alter TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace or create the object in another tablespace.

13.ORA-01578: oracle data block corrupted(file # num, block # num)

产生原因:当Oracle访问一个数据块时,由于

1. 硬件的I/O错误;

2. 操作系统的I/O错误或缓冲问题;

3. 内存或paging问题;

4. oracle试图访问一个未被格式化的系统块失败;

5. 数据文件部分溢出等上述几种情况的一种引起了逻辑坏块或者物理坏块,这时就会报ORA-01578的错误。

解决方法:由于Oracle只有在访问到有问题的数据文件时才会报错,所以报错的时间有可能会比实际出错的时间要晚,如果ORA-01578出错信息提示数据坏块指向的是用户自己的数据文件,则用以下方法来解决:

如果通过下面的SQL语句查出的坏块出现有索引上,则只需重建索引即可。

SQL>select owner, segment_name, segment_type

    from dba_extents

    where file_id= and between block_id and block_id+blocks-1;


如果坏块出现在表上,先用以下语句分析是否为永久性坏块(建议多执行一两次,有助于鉴别数据坏块是永久性的(硬盘上的物理坏块)还是随机性的(内存或硬件错误引起)):

SQL>Analyze table validate structure cascade;

执行该命令后,可能会出现以下的结果:

14.ORA-01578:与原先错误信息有相同的参数,为永久性的物理或逻辑坏块;与原先错误信息有不同的参数,可能与内存,page space和I/O设备有关。

如果用户有此表的最新备份,那么最好是用此备份来恢复此表,或者使用event 10231来取出坏块以外的数据:

1. 先关闭数据库

2. 编辑init.ora文件,加入:event="10231 trace name context forever, level 10"

3. startup restrict

4. 创建一个临时表:SQL>create table errortemp as select * from error;(error是坏表的表名)

5. 把event从init.ora文件中删掉并重起数据库

6. rename坏表,把临时表rename成坏表的表名

7. 创建表上的INDEX等

如果ORA-01578出错信息提示数据坏块指向的是数据字典或者是回滚段的话,你应该立即与ORACLE公司联系,共同商量一个好的解决办法。

这里所讲的解决方法只是比较常见的一种,一些更为具体的解决办法可以查看一下ORACLE的故障解决手册,那里面有浞及使用ROWID方法来取出坏块以外的数据的方法,这里就不介绍了。

相应的英文如下:

Cause: The given data block was corrupted,probably due to program errors

Action: Try to restore the segment containing the given data block,This may involve dropping the segment and recreating it,If there is a trace file,report the messages recorded in it to customer support.

15.ORA-01628: max # of extents num reached for rollback segment num

产生原因:这种错误通常为一个回滚段和一个表空间已经达到MAXEXTENTS参数设置的极限。要注意的是这个MAXEXTENTS不是该回滚段或表空间的硬件极限,硬件极限取决于数据库创建时在init.ora文件中指定的DB_BLOCK_SIZE参数的值。

解决方法:使用SQL命令Alter TABLESPACE…STORAGE(MAXEXTENTS XXXX)来增加MAXEXTENTS,其中“XXXX”值必须大于错误信息中所指的数值,但不能大于LARGEST MAXEXTENT的值,如果已经达到了LARGEST MAXEXTENT VALUE,解决的办法就是重新创建较大的范围尺寸,使用带有选项COMPRESS=Y的Export工具导出表,如果表空间有可用空间,先给表做一个备份,用alter tablespace tablespace_name更改其名字,然后再装载表回数据库。

查看其错误出现的地方,如果出现在回滚段或索引上,那么必须将其删除并重建,如果出现在临时表空间,修改临时表空间的存储字段,便可解决这个问题。



16.ORA-1628: max # extents 50 reached for rollback segment RBS_1

相应的英文如下:

Cause: An attempt was made to extend a rollback segment that already has reached its maximum size or space could not be allocated in the data dictionary to contain the definition of the object.

Action: If possible, increase the value of either the MAXEXTENTS or PCTINCREASE initialization parameters or find the data dictionary table lacking space and alter the storage parameters, as described in the oracle8 Server Administrator’s Guide.

17.ORA-00600: internal error code,arguments: [num], [?], [?], [?], [?]

产生原因:这种错误通常为Oracle的内部错误,只对OSS和Oracle开发有用。ORA-600的错误经常伴随跟踪文件的状态转储(系统状态和进程状态),系统状态存储将包括ORACLE RDBMS持有的当前对象的信息,进程状态转储则将显示特殊进程持有的对象,当进程符合了某错误条件时,经常是由于一些信息取自它持有的一个块,如果我们知道这些错误进程持有的块,就容易跟踪问题的来源。

解决方法:一般来说出现这个错误我们本身是无法解决的,只有从提高系统本身各方面来解决这个内部问题,如增加硬件设备、调整系统性能、使用OPS(当然OPS从某种意义上说并不是一种好的解决方式)等。ORA-600错误的第一个变量用于标记代码中错误的位置(代码中的每个部分的第一变量都不一样),从第二个到第五个变量显示附加信息,告诉OSS代码在哪里出现了错误。



18.ORA-00600: internal error code, arguments: [1237], [], [], [], [], [], [], []

相应的英文如下:

Cause: This is a catchall internal error message for oracle program exceptions.It indicates that a process has met a low-level,unexpected condition.Various causes of this message include:

Time-outs(超时)

File corruption(文件太老)

Failed data checks in memory(内存检索失败)

Hardware, memory, or I/O errors(硬件、内存或者磁盘错误)

Incorrectly restored files(错误的重建文件)


19.ORA-03113:end-of-file on communication channel

产生原因:通讯不正常结束,从而导致通讯通道终止。

解决方法:

1. 检查是否有服进程不正常死机,可从alert.log得知

2. 检查sql*Net Driver是否连接到ORACLE可执行程序

3. 检查服务器网络是否正常,如网络不通或不稳定等

4. 检查同一个网上是否有两个同样名字的节点

5. 检查同一个网上是否有重复的IP地址

相应的英文如下:

Cause: An unexpected end-of-file was processed on the communication channel. The problem could not be handled by the Net8,two task,software. This message could occur if the shadow two-task process associated with a Net8 connect has terminated abnormally, or if there is a physical failure of the interprocess communication vehicle,that is,the network or server machine went down.

Action: If this message occurs during a commection attempt, check the setup files for the appropriate Net8 driver and confirm Net8 software is correctly installed on the server. If the message occurs after a connection is well established, and the error is not due to a physical failure, check if a trace file was generated on the server at failure time. Existence of a trace file may suggest an oracle internal error that requires the assistance of customer support.

20.ORA-00942: table or view does not exist

产生原因:这是由于装载的表或视图不存在,多半是CATEXP.SQL还没有运行,无法执行Export视图,如果CATEXP.SQL已经运行,则可能是版本错误。

解决方法:因为Import和Export共享的一些视图是通过运行CATEXP.SQL来装载的(它们具有相同的视图),并不生成单独的CATEXP.SQL,因而造成视图与Export代码不同步,较难保持彼此之间的兼容,用户就必须建立自己的Export应用,从而避免ORA-00942的错误。

相应的英文如下:

Cause: The table or view entered does not exist, a synonym that is jnot allowed here was used, or a view was referenced where a table is required.Existing user tables and views can be listed by querying the data dictionary. Certain privileges may required to access the table. If an application returned this message, the table the application tried to access does not exist in the database, or the application does not have access to it.

Action: Check each of the following:

The spelling of the table or view name.

That a view is not specified where a table is required.

That an existing table or view name exists.

Contact the database administrator if the table needs to be created or if user or application priviledes are required to access the table.

Also, if attempting to access a table or view in another schema, make certain thecorrect schema is referenced and that access to the object is granted.

21.ORA-01598:rollback segment "name" is not online

Cause: The rollback segment was taken offline either manually or by SMON.

Action: Check the status of the rollback segment in DBA_ROLLBACK_SEGS.

22.ORA-1636: rollback segment "name" is already online

Cause: A rollback segment can only be used by one instance and an instance is trying to bring a rollback segment online that is already in use.

Action: Check that the values set in the initialization parameter file for parameters

ROLLBACK_SEGMENTS, ROLLBACK_SEGMENT_INITIAL, and ROLLBACK_SEGMENT_COUNT are correctly set for the instance whiththe problem. Also check that the instance is using the correct initialization parameter file. Make sure you are not confused about the difference between private and public rollback segments. See the oracle8 Server Administrator’s Guide for more information about using rollback segments in paraller mode.

上述错误均为我们在使用回滚段时比较常见的问题,ORA-01598指明当前使用的回滚段的状态为“not online”,不能使用,将它改为“online”状态即可使用;ORA-01636指明当前回滚段已经为“online”状态,可以直接使用,不用再集合它。

23.ORA-1636 signalled during: alter rollback segment rb00 online

我们在做统计时还可能遇到下述问题:一个rollback segment的状态为”Needs Recovery”的现象,这是由于ORACLE回退一个事物表中的没有提交的事物时失败所造成的。通常原因为一个datafile或者tablespace是在offline的状态或者一个undo的目标被破坏或者rollback segment被破坏。解决的办法是将所有的tablespace和datafile都置为online状态,如果不能解决则做下面的工作:

1. 在initsid.ora中加入event="10015 trace name context forever lever 10";

2. shutdown数据库然后重启;

3. 在$ORACLE_HOME/rdbms/log下,找到startup时生成的trace file;

4. 在trace文件中,找到下列信息"error recovery tx(#,#) object #";

5. 根据object#(与sys.dba_objects表中的object_id相同)在sys.dba_objects表中查出该object的名字;

6. 将该object drop掉;

7. 在init.ora文件中将该rollback segment放回rollback_segments参数中,删除event;

8. shutdown数据库然后重启。此时"Needs Recovery"的问题应该是完全解决了,否则就是rollback segment被破坏了。

24.ORA-01688:unable to extend table name.name partition NAME by NUM in tablespace NAME

产生原因:指定的tablespace空间已经被占用满,无法扩展。

解决方法:使用“Alter TABLESPACE ADD DATAFILE”命令增加文件系统文件和原始分区,或者增加INITIAL的大小(如:alter tablespace CDRS101 default storage(next 500M pctincrease 1))应该能够解决,否则就是有人使用你的表空间上创建了一个比较大的数据文件导致你的表空间不够用。



24.ORA-1688: unable to extend table RMMCDR.LOCAL_CDR partition LOCAL_CDR101 by 460800 in tablespace CDRS101

相应的英文如下:

Cause: An extent could not be allocated for a table segment in tablespace

Action: Use the Alter TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace



25.错误提示:FRM-41839:在临时记录缓冲区文件/tmp/ztYpaa.tmp中磁盘的输入/输入错误

原因:是/TMP目录的空间用完了



解决办法:(从metalink上找的)

•fact: oracle Application Object Library
•symptom: FRM-41839: Disk I/O error on temporary record buffer file
/var/tmp/AAAJGaa9Z.TMP
•symptom: Querying Values in a value set/Rows in row sets
•change: NOTE ROLE: Also note that per Note 157385.1, this error occurs when
a query is performed which returns a large number of records. Forms is trying
to create a temporary file in which to place the results of the query. There
is not enough disk space on the drive which is assigned to TEMP/TMP. Either
free up more space or move the TEMP directory to a different drive.
•cause: The /var/tmp referenced in the error message was on Web/Forms
tier.


fix:

There are 3 possible solutions:
1. Create a soft link to a mount point with more disk space
2. Add more disk space.
3. Set the TMPDIR environment variable and manually start the forms server. See


有些解决方案一下子记不得出处了,感谢提供解决方案的作者,谢谢。



PL/SQL显示行号:
tools> preferens >userinterface >editor >other  

Check display line numbers



orA-00972: identifier is too long.
*Cause:  An identifier with more than 30 characters was specified.
*Action:  Specify at most 30 characters.

应该是表空间名超过了30个字符。命名过长


PLS-00428: an INTO clause is expected in this Select statement

评论: 0 | 引用: 0 | 查看次数: 9989
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 30 字 | UBB代码 关闭 | [img]标签 关闭