[20171115]关于namespace.txt

[20171115]关于namespace.txt

--//第一次听到这个概念,好像是那篇blog提到,表与索引在不同的namespace里面.也就是在相同schema下建立的表可以与索引同名.
--//而在同一schema下的namespace的建立的对象名字是不能重名的.

--//前几天在测试dbms_shared_pool.pin时,发现SEQUENCE的namespace竟然是TABLE/PROCEDURE,感觉有必要做一些学习,了解这方面
--//的知识.

--//摘要: http://blog.csdn.net/tianlesoftware/article/details/6624122

Oracle通过namespace来管理schema object的名字,关于Namespace 的定义,在官网文档上没有找到一个详细的定义,在网上搜到一些相
关信息:

Schema Object Namespaces

A namespace defines a group of object types, within which all names must be uniquely identified—by schema and name.
Objects in different namespaces can share the same name.

The Oracle database uses namespaces to resolve schema object references. When you refer to an object in a SQL statement,
Oracle considers the context of the SQL statement and locates the object in the appropriate namespace. After locating
the object, Oracle performs 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 in the 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. This means, for example, that two tables
in different schemas are in different namespaces and can have the same name.

--以上解释提到了几点:

1.每个用户都有自己对应的namespace来保存自己的对象
2.表和视图存放在同一个namespace,所以对于同一个用户的表和视图不能重名,但是表和索引是存放在不同的namespace,所以可以重名。

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:
SYS@book> select distinct kglhdnsp,kglhdnsd,kglobtyd from x$kglob order by 1;
KGLHDNSP KGLHDNSD                        KGLOBTYD
-------- ------------------------------- ---------------------------------
       0 SQL AREA                        CURSOR
       1 TABLE/PROCEDURE                 CURSOR
       1 TABLE/PROCEDURE                 FUNCTION
       1 TABLE/PROCEDURE                 LIBRARY
       1 TABLE/PROCEDURE                 OPERATOR
       1 TABLE/PROCEDURE                 PACKAGE
       1 TABLE/PROCEDURE                 PROCEDURE
       1 TABLE/PROCEDURE                 SEQUENCE
       1 TABLE/PROCEDURE                 SYNONYM
       1 TABLE/PROCEDURE                 TABLE
       1 TABLE/PROCEDURE                 TYPE
       1 TABLE/PROCEDURE                 VIEW
       2 BODY                            CURSOR
       2 BODY                            PACKAGE BODY
       2 BODY                            TYPE BODY
       4 INDEX                           INDEX
       5 CLUSTER                         CLUSTER
      10 QUEUE                           QUEUE
      18 PUB SUB INTERNAL INFORMATION    PUB SUB INTERNAL INFORMATION
      23 RULESET                         RULESET
      24 RESOURCE MANAGER                RESOURCE MANAGER CONSUMER GROUP
      45 MULTI-VERSION OBJECT FOR TABLE  MULTI-VERSIONED OBJECT
      48 MULTI-VERSION OBJECT FOR INDEX  MULTI-VERSIONED OBJECT
      51 SCHEDULER GLOBAL ATTRIBUTE      CURSOR
      51 SCHEDULER GLOBAL ATTRIBUTE      SCHEDULER GLOBAL ATTRIBUTE
      52 SCHEDULER EARLIEST START TIME   SCHEDULER EARLIEST START TIME
      64 EDITION                         EDITION
      69 DBLINK                          CURSOR
      73 SCHEMA                          CURSOR
      73 SCHEMA                          NONE
      74 DBINSTANCE                      CURSOR
      75 SQL AREA STATS                  CURSOR STATS
      79 ACCOUNT_STATUS                  NONE
      82 SQL AREA BUILD                  CURSOR
34 rows selected.

--//个人感觉查询比较全,至少我机器正在运行的namespace.

https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements008.htm#SQLRF51109

Within a namespace, no two objects can have the same name.

The following schema objects share one namespace:
    Tables
    Views
    Sequences
    Private synonyms
    Stand-alone procedures
    Stand-alone stored functions
    Packages
    Materialized views
    User-defined types

Each of the following schema objects has its own namespace:
    Indexes
    Constraints
    Clusters
    Database triggers
    Private database links
    Dimensions

Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name.
However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the
same name.

Each schema in the database has its own namespaces for the objects it contains. This means, for example, that two tables
in different schemas are in different namespaces and can have the same name.

Each of the following nonschema objects also has its own namespace:

    User roles
    Public synonyms
    Public database links
    Tablespaces
    Profiles
    Parameter files (PFILEs) and server parameter files (SPFILEs)

Because the objects in these namespaces are not contained in schemas, these namespaces span the entire database.

--//注意看同义词,Private synonyms与table在一个名字空间里面,而 Public synonyms是分开单独的名字空间.
--//这些概念不小心还是乱...

--//继续做一些测试:

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:

SCOTT@book> CREATE SYNONYM DEPT FOR SCOTT.DEPT;
CREATE SYNONYM DEPT FOR SCOTT.DEPT
*
ERROR at line 1:
ORA-01471: cannot create a synonym with same name as object

--//而建立PUBLIC SYNONYM 就没有问题.

SCOTT@book> CREATE PUBLIC SYNONYM DEPT FOR SCOTT.DEPT;
Synonym created.

SCOTT@book> drop PUBLIC SYNONYM DEPT ;
Synonym dropped.

--//因为这两者属于不同的名字空间,这就很好理解.

时间: 2024-07-30 10:53:11

[20171115]关于namespace.txt的相关文章

[20171115]ZEROCONF ROUTE.txt

[20171115]ZEROCONF ROUTE.txt --//如果你检查linux服务器的网络配置,就可以发现如下一条路由: #  route -n | egrep "169.254|Destination" Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 169.254.0.0     0.0.0.0         255.255.0.0     U     0     

asp.net+Ajax 文本文件静态分页实现代码_AJAX相关

服务端部分 ,文本文件分页的类.主要在流中处理.当然我看过网上的用</br> 关键字进行分页的 个人觉得不是所有时候都能满足要求,所一自己写了这个,还是费了点时间,主要在于本人太笨,基础很差.希望大家个出更好的建议 复制代码 代码如下: using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Txt { public class TxtPager { public

C#记事本

using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace TXT { public partial class Form1 : Form

asp.net+Ajax 文本文件静态分页实现代码

服务端部分 ,文本文件分页的类.主要在流中处理.当然我看过网上的用</br> 关键字进行分页的 个人觉得不是所有时候都能满足要求,所一自己写了这个,还是费了点时间,主要在于本人太笨,基础很差.希望大家个出更好的建议 复制代码 代码如下: using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Txt { public class TxtPager { public

[20171115]关于逻辑读的疑问.txt

[20171115]关于逻辑读的疑问.txt --//有网友指出[20150209]为什么少1个逻辑读.txt,链接:http://blog.itpub.net/267265/viewspace-1430902/ --//如何验证是这样操作的. 1.环境: SCOTT@test> @ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- ----

[20171115]恢复数据文件块头3补充.txt

[20171115]恢复数据文件块头3补充.txt --// 昨天做了恢复数据文件块头,通过备份文件直接取出文件块头,覆盖原来的数据块,然后修复. --//补充几点: --1.文件头损坏,无法使用rman的块恢复功能. --2.文件头损坏,dbv检查发现都是坏块.我感觉主要文件块头损坏,dbv无法定位其它剩下的块. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --------

txt文件-c++如何控制文件输出的行数?

问题描述 c++如何控制文件输出的行数? 我有一个几千行的txt文件,里面都是ascall字符,我想每次读取30行在控制台显示然后清屏,延迟0.1s后再输出接下来的30行,也就是第一次控制台输出1-30行,清屏,第二次输出31-60行,这样一直下去,直到文件末尾 1. 我希望在每次在控制台显示的时候一次性显示30行的字符,必须一次性显示30行,肉眼不能察觉到是一行一行显示出来的. 解决方案 自己做个计数就好了,30行后,计数清零,重新计数 解决方案二: #include #include #in

C++ 怎么向一个txt文件的指定位置添加文本而不覆盖原有的内容?

问题描述 C++ 怎么向一个txt文件的指定位置添加文本而不覆盖原有的内容? 比如说有一个有文本的txt文件,我要在文本中间添加新文本,怎么做才能不覆盖原来的文本? 解决方案 文件追加,append 解决方案二: http://wenwen.sogou.com/z/q553022171.htmhttp://bbs.csdn.net/topics/390533611 这里有两个链接你看看对你有没有帮助 解决方案三: 以append方式打开 如果是想在一段内容中插入新的内容,就必须先保留插入位置以后

从数据库导出数据到word、excel、.txt

excel|word|导出数据|数据库 转自http://martinyang2010.bokee.com/2598999.htmlusing System;using System.Data;using System.Drawing;using System.Data.SqlClient;using Excel;using Word;using System.IO;namespace Common{ /// <summary> /// 把数据导入到.doc..txt..xls文件中 ///