ITPub博客

首页 > 数据库 > Oracle > [20191021]改名与namespace.txt

[20191021]改名与namespace.txt

原创 Oracle 作者:lfree 时间:2019-10-21 21:17:55 0 删除 编辑

[20191021]改名与namespace.txt

--//偶尔会给一些对象改名,会遇到一些容易引起歧义的地方,实际上由于namespace引起的.
--//通过例子说明:

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

create sequence seq1;
create view vdept as select * from dept;

2.改名测试:
SCOTT@test01p> rename seq1 to seq2;
Table renamed.

SCOTT@test01p> rename vdept to v_dept;
Table renamed.

--//我修改sequence以及view,而成功后提示是"Table renamed.",而实际上oracle这些对象在相同的namespace空间中.
--//也许你可以认为oracle处理这些问题简单化了.

SYS@test> select distinct kglhdnsp,kglhdnsd,kglobtyd from x$kglob order by 1;
KGLHDNSP KGLHDNSD                       KGLOBTYD
-------- ------------------------------ -----------------------------
    -119 OPTIMIZER EXPRESSION HEADER    Optimizer Expression Header
       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
       3 TRIGGER                        CURSOR
       3 TRIGGER                        TRIGGER
       4 INDEX                          INDEX
       5 CLUSTER                        CLUSTER
       5 CLUSTER                        CURSOR
      10 QUEUE                          QUEUE
      18 PUB SUB INTERNAL INFORMATION   PUB SUB INTERNAL INFORMATION
      23 RULESET                        RULESET
      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
      64 EDITION                        EDITION
      69 DBLINK                         CURSOR
      73 SCHEMA                         NONE
      74 DBINSTANCE                     CURSOR
      75 SQL AREA STATS                 CURSOR STATS
      82 SQL AREA BUILD                 CURSOR
      93 AUDIT POLICY                   AUDIT POLICY
     103 OPTIMIZER FINDING              Optimizer Finding
     104 OPTIMIZER DIRECTIVE OWNER      CURSOR
     104 OPTIMIZER DIRECTIVE OWNER      Optimizer Directive Owner
38 rows selected.

--//可以发现CURSOR, FUNCTION, LIBRARY, OPERATOR, PACKAGE, PROCEDURE, SEQUENCE, SYNONYM, TABLE, TYPE, VIEW在相同的名字空间.
--//也就是这些对象不允许重名.

SCOTT@test01p> rename seq2 to v_dept;
rename seq2 to v_dept
               *
ERROR at line 1:
ORA-00955: name is already used by an existing object

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2660882/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2506
  • 访问量
    6307414