oracle 序列(sequence)和索引(index)

oracle 序列(sequence)和索引(index)
1.序列
(1.建表)
create table product(
pid number primary key,
pname varchar2(30)
);
oracle 序列(sequence)和索引(index)
(2.建立序列)
create sequence PRODUCT_SEQ   --序列名  
minvalue 1  --最小值
maxvalue 9999999999999999999999999999--最大值
start with 1  --开始的数据
increment by 1  --每次增加1
cache 20;   --缓冲大小20M
oracle 序列(sequence)和索引(index)
(3.插入数据)
insert into product values(product_seq.nextval,'苹果');
insert into product values(product_seq.nextval,'香蕉');
insert into product values(product_seq.nextval,'桂圆');
 
2.索引
------primary key = index + unique  主键就等于索引加唯一
索引:主要作用是调高查询效率
优点:调高效率
缺点: 1.降低了数据更新的效率 2.增加了存储空间
使用规则:数据量大,常用的栏目上建立索引
常用查询的栏目才建立索引,并不是所有的位置建立索引都好,而且索引不超过四个
建立索引的语法:
create index indexname on tablname(cloumn);
 
在学生的表上的分数栏目上建立一个叫index_score的索引
create index index_score on student(score);