日期:2014-05-16 浏览次数:20500 次
为了对比明显,我们创建一个数据比较多的表:
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 on
SQL> 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.20
4、基于函数的索引
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;