码迷,mamicode.com
首页 > 其他好文 > 详细

【翻译自mos文章】为table 的partition 建立synonym

时间:2015-04-11 17:55:48      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:table   partition   synonym   

本文参考自:

How to Create a Synonym on a Table Partition (Doc ID 119805.1)

 

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>


 

【翻译自mos文章】为table 的partition 建立synonym

标签:table   partition   synonym   

原文地址:http://blog.csdn.net/msdnchina/article/details/44997279

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!