Oracle 索引,同义词,序列

索引用于快快速访问数据
创建索引
Oracle P143
create index ixnameon on student(sname,tc);
修改索引
alter index ixgrade rename to ixgradescore
删除索引
Drop index ixgradescore
同义词用于简化数据库对象的访问,另外提供了一定的安全性保障
公有同义词,私有同义词
public synonym ,private synonym
创建同义词
create public synonym htyscore for system.score
使用同义词 并用SCOTT 用户访问,
解开scott用户的锁
conn /as sysdba
alter user scott account unlock;
切换用户system,
授予权限给scott,
grant select on score to scott
连接scott
conn scott/tiger
select * from htyscore;
删除同义词
drop public synonym htyscore;
序列是一种数据库对象,定义在数据字典中,用来自动产生一组唯一的序号,序列是一种共享式的对象,多个用户可以共同使用序列中的序号。
创建序列
create sequence seqCustomer
increment by 1 递增或递减
start with 100001 初始值
maxvalue 999999 最大值
nocycle 是否循环
nocache 高速缓冲区设置
order 序列号是序列否,按照顺序生成
使用序列
insert into customer values(seqCustomer.nextval,’555’,’6666’);
修改序列
alter sequence seqCustomer
increment by 2;参数同上
删除序列
drop sequence seqCustomer

猜你喜欢

转载自blog.csdn.net/weixin_37543460/article/details/78369776