索引巧建
来源:互联网 发布:营养配餐软件正式版 编辑:程序博客网 时间:2024/05/05 19:29
SQL> conn /as sysdba
Connected.
--添加一列 alter table person add birthday date;
--select sysdate from dual;
--时间戳 select systimestamp from dual;
--rowid物理地址 rownum 数据行
SQL> select rowid,rownum,dept.* from scott. dept;
ROWID ROWNUM DEPTNO DNAME LOC
------------------ ---------- ---------- -------------- -------------
AAAL+XAAEAAAAANAAA 1 10 ACCOUNTING NEW YORK
AAAL+XAAEAAAAANAAB 2 20 RESEARCH DALLAS
AAAL+XAAEAAAAANAAC 3 30 SALES CHICAGO
AAAL+XAAEAAAAANAAD 4 40 OPERATIONS BOSTON
AAAL+XAAEAAAAANAAE 5 50 aa aa
SQL> select rowid,rownum,dept.* from scott. dept where rownum<3;
ROWID ROWNUM DEPTNO DNAME LOC
------------------ ---------- ---------- -------------- -------------
AAAL+XAAEAAAAANAAA 1 10 ACCOUNTING NEW YORK
AAAL+XAAEAAAAANAAB 2 20 RESEARCH DALLAS
---rownum随时会变,所以为空
SQL> select rowid,rownum,dept.* from scott. dept where rownum>3;
no rows selected
--利用rownum 实现分页,但必须把(select rownum num,dept.* from scott.dept)做为固定视图
SQL> select * from (select rownum num,dept.* from scott.dept) where num>=3 and n
um<5;
NUM DEPTNO DNAME LOC
---------- ---------- -------------- -------------
3 30 SALES CHICAGO
4 40 OPERATIONS BOSTON
--distinct 去掉重复行
SQL> select distinct deptno from emp;
DEPTNO
----------
10
20
30
40
50
---save transaction=savepoint创建保留点
SQL>savepoint p1;insert into person values(5,'aa',sysdate) rollback to p1;
--视图
--键保留表(视图中的主键为表的主键)
--不能同时修改两张表,除非主键都是键保留,只能修改键保留表中数据
----索引
--oracle 中索引按照rowid排序,其结构为平衡二叉树 及遍历 2的对数次
--重建索引,当oracle 自定义的结构不平衡时。
--反向键索引 当统计中国百家姓的情况reverse
--create index re_index on itemfile(itemcode) reverse
--位图索引适合创建在低基数列上(男女),因为它不直接存储在rowid上,而是存储字节位到rowid的映
射上
declare name varchar2(20);
no number;
begin
no:=7369;
select ename into name from emp where empno=no;
dbms_output.put_line(name);
exception
when no_data_found then
dbms_output.put_line('未找到该数据');
end;
declare score number;
begin
score:=&score;
if(score>100) then
dbms_output.put_line('成绩非法');
elsif(score>90) then
dbms_output.put_line('A');
elsif(score>80) then
dbms_output.put_line('B');
elsif(score>70) then
dbms_output.put_line('C');
elsif(score>60) then
dbms_output.put_line('D');
else
dbms_output.put_line('E');
end if;
end;
declare no emp.empno%type;
rec emp%rowtype;
begin
no:=&no;
select * into rec from emp where empno=no;
dbms_output.put_line(rec.deptno||':'||rec.ename);
end;
- 索引巧建
- 建好索引,用好索引
- mysql 建立索引(sql 建索引)
- mysql 建索引删除索引命令
- 适合建索引?不适合建索引?分析
- mysql建索引原则及索引区别
- 建了索引却不走索引案例分析
- mysql 建索引问题
- 建简单索引
- informix建索引
- 如何建索引
- SQLCE建复合索引
- DB2 建索引SQL
- 数据库建索引
- 怎样建高效索引
- PowerDesigner下建索引
- 数据库建索引规则
- 反向建索引
- LNK2005错误——重复定义错误
- fedora 10下mplayer安装指南
- 病的不轻
- 北斗/GPS冗余对时系统
- URL中的特殊字符
- 索引巧建
- test
- 高压开关柜温度监测系统、高压开关柜测温系统
- 推荐一篇网络安全方面的文章,介绍HTTPS
- 我公司供应手机物料如下
- 电缆温度监测系统、电缆接头测温系统
- oracle高级分组
- Early, smaller version of T. rex discovered
- Winodws Socket I/O模型的整理