(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);
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);