When a schema object is referenced directly in a SQL statement or indirectly through a
reference to a dependent object, Oracle checks the status of the object explicitly
specified in the SQL statement and any referenced objects, as necessary. Oracle’s action
depends on the status of the objects that are directly and indirectly referenced in a SQL
statement:
■ If every referenced object is valid, then Oracle runs the SQL statement
immediately without any additional work.
■ If any referenced view or PL/SQL program unit (procedure, function, or package)
is invalid, then Oracle automatically attempts to compile the object.
■ If all invalid referenced objects can be compiled successfully, then they are
compiled and Oracle runs the SQL statement.
■ If an invalid object cannot be compiled successfully, then it remains invalid.
Oracle returns an error and rolls back the failing SQL statement. The rest of the
transaction is unaltered and can be committed or rolled back by the user.
Note: Oracle attempts to recompile an invalid object dynamically
only if it has not been replaced since it was detected as invalid. This
optimization eliminates unnecessary recompilations.
解析方案对象的依赖性
1. 如果所有的引用对象均处于有效状态,则 Oracle直接执行 SQL 语句
2. 如果 SQL 语句中存在无效的引用视图或 PL/SQL 程序结构,Oracle 将自动地尝试编译这些对象
如果编译成功 , 执行SQL 语句
如果有任何一个引用对象编译不成功,则继续保持无效状态 ,Oracle 回滚执行失败的 SQL 语句并返回一个错误信息
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-983757/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10599713/viewspace-983757/
本文详细介绍了Oracle数据库在执行SQL语句时如何检查直接和间接引用的对象状态。当SQL语句引用的对象有效时,Oracle立即执行;若引用了无效的视图或PL/SQL程序单元,则Oracle会尝试自动编译。文章还解释了不同情况下Oracle的具体行为及错误处理方式。
724

被折叠的 条评论
为什么被折叠?



