您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle之索引(Index)实例讲解

2024/12/27 16:07:54发布29次查看
oracle索引(index)是关系数据库中用于存放表中每一条记录位置的一种对象,主要目的是加快数据的读取速度和数据的完整性检查。索引
oracle索引(index)是关系数据库中用于存放表中每一条记录位置的一种对象,主要目的是加快数据的读取速度和数据的完整性检查。索引的建立是一项技术性要求非常高的工作。
一般在数据库设计阶段就要考虑到如何设计和创建索引。
1. 创建索引
创建索引的语法:
 create [unique] index [schema.] index
on [schema.] table (column [asc | desc], column [asc | desc]...)
[cluster schema.cluster]
[initrans n]
[maxtrans n]
[pctfree  n]
[storage storage]
[tablespace tablespace]
[no sort]
关键字说明:
示例:创建一张产品表(tb_product),为该表的product_id列创建索引,以便在使用到该列时提高查询效率。
create table tb_product
(
  product_id              number
, product_name            varchar2(100)
, product_type            varchar2(20)
, product_unit            varchar2(50)
, product_unit_price      number(10,4)
);
下面代码用来在product_id列上创建唯一索引:
create unique index product_id_u1 on tb_product(product_id);
2. 修改索引
索引的修改主要由数据库管理员完成,,修改索引主要涉及到修改索引的存储参数、重建索引、对无用的索引空间进行合并等。
修改索引的语法:
alter [unique] index [user.] index
initrans n
maxtrans n
rebuild
[storage ]
说明:
示例:
使用alter index语句修改索引参数:
alter index product_id_u1 rebuild storage  ( initial 1m next 512k );
使用alter index语句修改索引为逆向索引:
alter index product_id_u1 rebuild reverse;
使用alter index语句合并索引空间:
alter index product_id_u1 coalesce;
3. 删除索引
可以使用drop语句删除索引。
drop index schema.index;
在centos 6.4下安装oracle 11gr2(x64)
oracle 11gr2 在vmware虚拟机中安装步骤
debian 下 安装 oracle 11g xe r2
oracle性能优化 之 共享池
作者: 戴维德 联系方式:david.louis.tian@outlook.com
本文永久更新链接地址:
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product