本文内容
- 创建非聚簇的相关表
- 创建聚簇
- 简单查询比较
本文简单比较建立聚簇后,对查询的影响。虽然就几条数据,但多少也能说明点问题。有机会的话,再试下大数据量的比较。
创建非聚簇的相关模式对象
创建 EMPLOYEES 和 DEPTMENTS 表。
-- Create table
create table EMPLOYEES
(
EMPNO NUMBER(4) not null,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(3)
)
tablespace MYTBS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table EMPLOYEES
add constraint PK_EMPLOYEES_EMPNO primary key (EMPNO)
using index
tablespace MYTBS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create table
create table DEPTMENTS
(
DEPTNO NUMBER(3) not null,
DNAME VARCHAR2(14),
LOC VARCHAR2(13)
)
tablespace MYTBS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table DEPTMENTS
add constraint PK_DEPTMENTS_DEPTNO primary key (DEPTNO)
using index
tablespace MYTBS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);