oracle 重建索引

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_25391785/article/details/88716418
-- Create table 
create table PHONEDICT
(
  ID        INTEGER not null,
  DICTVALUE VARCHAR2(200) not null,
  TIME      DATE default sysdate,
  DICTTYPE  INTEGER,
  USERID    VARCHAR2(60),
  STATUS    NUMBER(2)
)
tablespace TEST_DATA
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 128K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Create/Recreate primary, unique and foreign key constraints (一下是三个索引)
alter table PHONEDICT
  add constraint PK_PHONEDICT primary key (ID)
  using index 
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Create/Recreate indexes 
create index IDX_DICTTYPE on PHONEDICT (DICTTYPE)
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
create index IDX_DICTVALUE on PHONEDICT (DICTVALUE)
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 128K
    next 1M
    minextents 1
    maxextents unlimited
  );

当我在执行insert into 的时候发现 PK_PHONEDICT 索引失效了,

需要重建索引:

alter index PK_PHONEDICT rebuild tablespace USERS;

注:PK_PHONEDICT 为索引名,USERS 为表空间;不要把列名当成索引名

如图所示:

猜你喜欢

转载自blog.csdn.net/qq_25391785/article/details/88716418