执行计划跟踪

(1)explain plan for方法
SQL>explain plan for select * from dept
select * from table(dbms_xplan.display);
(2)set autotrace 方法
set autotrace traceonly explain
(3)关于set autotrace有几种方法
1.set autotrace off ---不生产autotrace 报告
2.set aurotrace on explain ---包含执行计划,查询结果
3.set autotrace on statitics ---只包含统计信息,查询结果
4.set autotrace on ----包含执行计划,统计信息,查询结果
5.set autotrace traceonly --包含执行计划,统计信息
6.set autotrace traceonly explain ---只包含执行计划




范围分区
-----------------------------------------范围分区-----------------------------------  
create table test_range  
(  
  id      number(9),  
  name    varchar2(512),  
  week_no number(2)  
)  
tablespace USERS  
  storage  
  (  
    initial 64K  
    minextents 1  
    maxextents unlimited  
  )  
partition by range (week_no)  
(  
  partition p1 values less than (13) tablespace USERS  
    storage  
    (  
      initial 64K  
      minextents 1  
      maxextents unlimited  
    ),  
  partition p2 values less than (26) tablespace USERS  
    storage  
    (  
      initial 64K  
      minextents 1  
      maxextents unlimited  
    ),  
  partition p3 values less than (39) tablespace USERS  
    storage  
    (  
      initial 64K  
      minextents 1  
      maxextents unlimited  
    ),  
  partition p4 values less than (52) tablespace USERS  
    storage  
    (  
      initial 64K  
      minextents 1  
      maxextents unlimited  
    )  
);  
-----加主键--------  
alter table test_range add constraint pk_test_range primary key (ID);  


2、  哈希(Hash)分区
采用Hash算法,将数据均匀分布到各个分区
整体性能比较好,并且针对各个分区的数据的查询性能也是差不多的,
但是该分区算法适合于不经常删除的数据,例如中国十几亿人口的人员信息,单位固定资产信息,数据一旦插入就很少删除了。
同时该分区方式不适合大批量数据操作,例如历史数据的清理,数据导入导出
 
[sql] view plain copy
------------------------------------------HASH分区-----------------------------------  
create table test_hash  
(  
  id   number(9),  
  name varchar2(512),  
  code varchar2(18)  
)  
tablespace USERS  
  storage  
  (  
    initial 64K  
    minextents 1  
    maxextents unlimited  
  )  
partition by hash (code)  
(  
  partition p1 tablespace USERS,  
  partition p2 tablespace USERS,  
  partition p3 tablespace USERS,  
  partition p4 tablespace USERS  
);  
/*还可以这样写  
create table test_hash  
(  
  id   number(9),  
  name varchar2(512),  
  code varchar2(18)  
)  
tablespace USERS  
  storage  
  (  
    initial 64K  
    minextents 1  
    maxextents unlimited  
  )  
partition by hash (code) partitions 4 store in  
(  
 USERS,USERS,USERS,USERS  
);  
*/  
-----加主键--------  
alter table test_hash add constraint pk_test_hash primary key (ID);  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值