序列

--create sequence

create sequence empseq
increment by 10
start with 10
maxvalue 100
cycle--need cycle
nocache--needn't cache


--查询序列
select sequence_name,min_value,max_value,increment_by,last_number
from user_sequences


--查找下一个值
select empseq.nextval from dual
--查找当前值
select empseq.currval from dual

--修改序列[不能更改启动序列号]
alter sequence empseq
increment by 1
nocycle
nocache

--删除序列

--使用序列作为主键向表中插入值
insert into emp01
values(empseq.nextval,'AA',5500)

索引和同义词

--创建索引
create index emp01_id_ix
on emp01(employee_id)


--删除索引
drop index emp01_id_ix;

--创建同义词;
create synonym e for employees

select * from e

--删除同义词
drop synonym e;