Oracle基本的常用的对象
一、索引
1、索引的分类
按索引列的个数,索引分为单列索引和复合索引。
按索引列的唯一性,索引分为唯一索引和非唯一索引。
2、索引的组成
索引有两个部分组成,索引列所对应的值和行地址(ROWID,即原表中列所对应的行地址)。
3、索引的创建
为了对比明显,我们创建一个数据比较多的表: SQL> create table test1 as select * from dba_objects; SQL> insert into test1 select * from test1; 已创建50341行。
SQL> insert into test1 select * from test1; 已创建100682行。 SQL> select count(*) from test1; COUNT(*)----------201364 打开Oracle的计数器 SQL> set timing onSQL> select * from test1 where object_name='test1';已用时间: 00: 00: 00.17在object_name上创建索引SQL> create index test1_on on test1(object_name);SQL> select * from test1 where object_name='test1';已用时间: 00: 00: 00.204、基于函数的索引SQL> create index test1_on_l on test1(lower(object_name));SQL> select * from test1 where lower(object_name)='test1';5、删除索引SQL> drop index test1_on_l;
SQL> create synonym table1 for test1;
2、删除同义词SQL> drop synonym table1;
SQL> create sequence seq1 2 increment by 2 3 start with 1 4 maxvalue 20 5 nocycle;通过下面的语句可以查询创建的序列的信息SQL> select sequence_name,min_value,max_value, increment_by,last_number from user_sequences;2、序列的使用 SQL> select seq1.nextval from dual;SQL> select seq1.currval from dual;3、序列的修改SQL> alter sequence seq1 cycle nocache;4、删除序列SQL> drop sequence seq1;