Welcome 微信登录

首页 / 数据库 / MySQL / Oracle Namespace 说明

一. 初识Namespace

Oracle通过namespace来管理schema object的名字,关于Namespace 的定义,在官网文档上没有找到一个详细的定义,在网上搜到一些相关信息:SchemaObject Namespaces            A namespace defines a group of object types, within whichall names must be uniquely identified—by schema and name. Objects in differentnamespaces can share the same name.
            The Oracle database usesnamespaces to resolve schema object references. When you refer to an object ina SQL statement, Oracle considers the context of the SQL statement and locatesthe object in the appropriate namespace. After locating the object, Oracleperforms the operation specified by the statement on the object. If the named object cannot be found in the appropriate namespace,then Oracle returns an error.
            Because tables and views are in the same namespace, a table and a view inthe same schema cannot have the same name. However, tables and indexesare in different namespaces. Therefore, a table and an index in the same schemacan have the same name.
            Eachschema in the database has its own namespaces for the objects it contains. Thismeans, for example, that two tables in different schemas are in differentnamespaces and can have the same name.--以上解释提到了几点:            1.每个用户都有自己对应的namespace来保存自己的对象            2.表和视图存放在同一个namespace,所以对于同一个用户的表和视图不能重名,但是表和索引是存放在不同的namespace,所以可以重名。            开始时,我们提到Oracle 通过schema 和 name 来保证namespace中对象的唯一性。 在obj$ 字典里owner# 对应用户的ID。 通过如下SQL,我们可以查看他们之间的对应关系:            /* Formatted on 2011/7/21 15:41:26(QP5 v5.163.1008.3004) */SELECT username,user_id  FROM dba_usersWHERE user_id IN (SELECT DISTINCTowner# FROM obj$);USERNAME                     USER_ID------------------------- ----------SYS                                0SYSTEM                             5DBSNMP                            24SYSMAN                            58DAVE                              61OUTLN                             11MDSYS                             46ORDSYS                            43CTXSYS                            36EXFSYS                            34DMSYS                             35WMSYS                             25XDB                               38ORDPLUGINS                        44SI_INFORMTN_SCHEMA                45OLAPSYS                           47SCOTT                             54ORACLE_OCM                        55TSMSYS                            2119 rows selected. 一个小示例验证以上结论:SYS@anqing2(rac2)> createtable anqing(id number);Table created.SYS@anqing2(rac2)>create index anqing on anqing(id);Index created.SYS@anqing2(rac2)>create view anqing as select * from anqing;create view anqing asselect * from anqing            *ERROR at line 1:ORA-00955: name isalready used by an existing object 以下类型的对象使用同一个namespace:? Tables
? Views
? Sequences
? Private synonyms
? Stand-alone procedures
? Stand-alone stored functions
? Packages
? Materialized views
? User-defined types
 如下类型的对象使用自己的namespace:? Indexes
? Constraints
? Clusters
? Database triggers
? Private database links
? Dimensions
 以下Non schema objects 使用自己的namespace:? User roles
? Public synonyms
? Public database links
? Tablespaces
? Profiles
? Parameter files (PFILEs) and server parameter files (SPFILEs)以上信息随Oracle 版本不同,可能有出入。
  • 1
  • 2
  • 3
  • 下一页
Oracle中执行计划的存储位置Oracle 高 Version counts 问题说明相关资讯      Oracle教程 
  • Oracle中纯数字的varchar2类型和  (07/29/2015 07:20:43)
  • Oracle教程:Oracle中查看DBLink密  (07/29/2015 07:16:55)
  • [Oracle] SQL*Loader 详细使用教程  (08/11/2013 21:30:36)
  • Oracle教程:Oracle中kill死锁进程  (07/29/2015 07:18:28)
  • Oracle教程:ORA-25153 临时表空间  (07/29/2015 07:13:37)
  • Oracle教程之管理安全和资源  (04/08/2013 11:39:32)
本文评论 查看全部评论 (0)
表情: 姓名: 字数