同义词,索引,表分区

 同义词:数据字典

      作用:屏蔽对象的名字及其持有者,为用户简化SQL语句。

     创建私有同义词:

      create synonym ee for scott.emp

    授权:  grant  create  synonym  to  happyy2165

   grant create synonym to SCOTT

GRANT CREATE PUBLIC SYNONYM TO scott;

   公有同义词:  数据库中任何一个用户都默认拥有public角色

       create  public  synonym  tt  from  scott.emp    

select  *  from  SYS.ALL _SYNONYMS  where  table_Name='EMP'

    删除:

      grant  drop  public  synonym  to scott


  grant select on emp to 具体的用户或者是模式

grant select on emp to public

索引
  索引作用:快速访问数据的途径,提高数据库的性能。
  SQL Server 索引:唯一索引(1)  复合索引  聚集索引(3) 非聚集索引 全文 索引  主键索引(2)。
  
  B数索引

  优点:对于连续增长的索引列,反转索引列可以将索引数据分散,在多个索引快间,减少了I/O瓶颈发生。

 位图索引: 适用于低基数列

                    减少响应时间,省时间。

 sort:自定义序列 Comparable <student>

  表分区

    优点:   改善查询性能

                  表更容易管理

                  便于备份和恢复

                  提高数据安全性

  分区表的设定原则:

        数据大于2G,已有数据和新数据的数据有一个明显的分类。

    create table orders
  (
    order_id number,
    order_date date,
    order_total number
  ) 
partition by range(order_date)
(
   partition p1 values less than (to_date('2005-01-01','yyyy-mm-dd')),
   partition p2 values less than (maxvalue)
   
)


--添加数据
insert into orders values(1,sysdate,100)


select * from orders  partition(p2)


SELECT table_name,partition_name 
     FROM user_tab_partitions 
WHERE table_name=UPPER('orders');
 


create table intervalOrders
 partition by range(order_date)
interval(numtoyminterval(1,'YEAR'))
(partition P1 values less than (to_date('2015-01-01','yyyy/mm/dd')))
        as select  * from  orders;   
   
   insert into intervalOrders values(2,to_date('2010-01-01','yyyy/mm/dd'),200)
   
   select * from intervalOrders partition(SYS_P42)
   
   
   insert into intervalOrders values(3,sysdate,300)

原文地址:https://www.cnblogs.com/wangbenqing/p/7545661.html