Object Name Resolution (248)

tsinglee發表於2007-11-25

Object names referenced in SQL statements can consist of several pieces, separated by
periods. The following describes how Oracle resolves an object name.
1. Oracle attempts to qualify the first piece of the name referenced in the SQL
statement. For example, in hr.employees, hr is the first piece. If there is only one
piece, then the one piece is considered the first piece.
a. In the current schema, Oracle searches for an object whose name matches the
first piece of the object name. If it does not find such an object, then it
continues with step b.
b. Oracle searches for a public synonym that matches the first piece of the name.
If it does not find one, then it continues with step c.
c. Oracle searches for a schema whose name matches the first piece of the object
name. If it finds one, then it returns to step b, now using the second piece of
the name as the object to find in the qualified schema. If the second piece does
not correspond to an object in the previously qualified schema or there is not a
second piece, then Oracle returns an error.
If no schema is found in step c, then the object cannot be qualified and Oracle
returns an error.

2. A schema object has been qualified. Any remaining pieces of the name must match
a valid part of the found object. For example, if hr.employees.department_id
is the name, then hr is qualified as a schema, employees is qualified as a table,
and department_id must correspond to a column (because employees is a
table). If employees is qualified as a package, then department_id must
correspond to a public constant, variable, procedure, or function of that package.

Because of how Oracle resolves references, it is possible for an object to depend on the
nonexistence of other objects. This situation occurs when the dependent object uses a
reference that would be interpreted differently were another object present.

解析物件名稱
1. 在 SQL 語句中引用的方案物件名稱可由多段組成,各段之間使用“.”分隔
a. 在當前方案中搜尋名稱與物件名首段相符的物件 , 不存在進入步驟b
b. 搜尋名稱與物件名稱首段相符的公有同義詞 , 不存在進入步驟c
c. Oracle 搜尋名稱與物件名稱首段相符的方案。如果找到一個這樣的方案,則返回步驟 b,使用物件名稱的第二段
在方案中搜尋相符的物件。如果方案中不存在相符的物件,或者引用的物件名稱只由一段構成,則 Oracle 將返回一個錯誤
如果在步驟 c 中沒有找到相符的方案,那麼引用的物件名稱也不能被驗證,Oracle 將返回一個錯誤

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-984632/,如需轉載,請註明出處,否則將追究法律責任。

相關文章