如何知道我的会话中可以使用哪些模式?

时间:2019-04-23 17:34:33

标签: oracle plsql

当我以MY_NAME登录时,MY_NAME将是我的当前模式(可以使用SET CURRENT SCHEMA语句更改该模式)。

SELECT * FROM ALL_OBJECTS将显示“所有模式”中所有可用的对象。但是,如何找到可用的模式以及以什么顺序可用的文件,类似于文件系统中的PATH?

1 个答案:

答案 0 :(得分:1)

没有“可用”模式(“ schemata”)的概念。模式实际上只不过是属于给定所有者的对象集。唯一可用的是单个对象。即使在对象级别,也没有可用的“顺序”概念。要解析给定的不合格对象名称:

管理对象名称解析

SQL语句中引用的对象名称可以由几部分组成,并用句点分隔。下面介绍数据库如何解析对象名称。

Oracle Database attempts to qualify the first piece of the name referenced in the SQL statement. For example, in scott.emp, scott is the first piece. If there is only one piece, the one piece is considered the first piece.

    In the current schema, the database searches for an object whose name matches the first piece of the object name. If it does not find such an object, it continues with step b.

    The database searches for a public synonym that matches the first piece of the name. If it does not find one, it continues with step c.

    The database searches for a schema whose name matches the first piece of the object name. If it finds one, 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, the database returns an error.

If no schema is found in step c, the object cannot be qualified and the database returns an error.

https://docs.oracle.com/cd/B28359_01/server.111/b28310/general008.htm#ADMIN11561

如果要查看哪些架构具有当前用户可能引用的对象,则可以:

select distinct owner
from all_objects
order by owner;