设为首页 加入收藏

TOP

为table的partition建立synonym
2015-07-24 12:04:30 来源: 作者: 【 】 浏览:25
Tags:table partition 建立 synonym

How to Create a Synonym on a Table Partition:

=============================================

You cannot directly create a synonym on a table partition by specifying the 
partition name and table name with the CREATE SYNONYM command.  You have 
to create a view on the partition, and then create a synonym on the view.  
This is a two-step method instead of a single-step method.

Follow the steps in this example to create the synonym:

 $ sqlplus scott/tiger

 SQL> create table emp_pt
      ( empno number primary key,
        ename varchar2(30))
      partition by range (empno)
      ( partition p8000 values less than (8001),
        partition p9000 values less than (9001),
        partition p10000 values less than (10001),
        partition pothers values less than (99999999));

 SQL> insert into emp_pt
      select empno, ename from emp;
 
       --- Populated the partition table EMP_PT with existing 
       --- data from the EMP table.

 SQL> commit;

 SQL> select * from emp_pt;

      EMPNO ENAME
      ----- -----------------
      7369  SMITH
      7499  ALLEN
      7521  WARD
      7566  JONES
      7654  MARTIN
      ...
      9999  ANDY


 SQL> select * from emp_pt partition (p8000);

      EMPNO ENAME
      ----- ---------------------
      7369  SMITH
      7499  ALLEN
      7521  WARD
      7566  JONES
      7654  MARTIN
       ...
      7934  MILLER

 SQL> create view emp_pt_p8000 as select * from emp_pt partition (p8000);

 SQL> desc emp_pt_p8000
 
      Name                                Null?    Type
      ----------------------------------- ------ -----------   
      EMPNO                                       NUMBER
      ENAME                                       VARCHAR2(30)

 SQL> create synonym p8000 for emp_pt_p8000;

 SQL> desc p8000
     
      Name                                Null?    Type
      ----------------------------------- ------ -----------   
      EMPNO                                       NUMBER
      ENAME                                       VARCHAR2(30)
    
SQL> select * from p8000;

     EMPNO ENAME
     ----- ------------------------------
     7369 SMITH
     7499 ALLEN
     7521 WARD
     7566 JONES
     7654 MARTIN
     ...
     7934 MILLER

 SQL>

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LeetCode OJ Duplicate Emails 下一篇DS之栈

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: