reate table fleet_header(
  day date,name varchar2(20),
  route_id number(5),fleet_id number(5)
);

create view fleet (day,route_id)
as select day, route_id from fleet_header;

insert into fleet values('10-10月-05',9);

--修改视图定义

create or replace view fleet as select * from fleet_header;

--删除视图
drop view fleet;

--如何在fleet_header表的name 列上创建名为aud_index的索引
create index aud_index on fleet_header(name);

--创建唯一索引
--如何在fleet_header表的route_id 列上创建名为aud_index的索引
create unique index place_ind on fleet_header(route_id)

--创建组合索引
create index comp_index on fleet_header(route_id,fleet_id)

--创建反向键索引
--fleet_header表的route_id列值是一个顺序增长的序号,
--需要在此列上创建索引以提高查询速度
create index rev_ind on fleet_header(route_no) reverse;

--创建位图索引
create bitmap index bit_ind on fleet_header(cat._code);

--创建位图索引
create index ucase_name_ind on fleet_header (upper(name));
--输入以下语句使用该索引
select * from fleet_header where upper(name)='smith';

--删除索引
drop index emp_ind1;

----------------------------------------
--使用条件控制
----------------------------------------
create table salary_records
(
             deptcode varchar2(15),
            empcode varchar2(10),
            empsal  number
)

insert into salary_records
values('DP04','A4',0)

declare
   dptcode varchar2(15);
   emp_code varchar2(10);
   salary number;
begin
   select deptcode,empcode,empsal into dptcode,emp_code,salary
   from salary_records where empcode='&empid'

for update of empsal;

IF dptcode ='DP01' then
      update salary_records set empsal=salary+2000
      where empcode=emp_code;
   elsif dptcode ='DP01' then
       update salary_records set empsal=salary+1700
      where empcode=emp_code;
   elsif dptcode='DP03' then
       update salary_records set empsal=salary+2000
      where empcode=emp_code;
   end if;
commit;
end;

-----------------------------------------------
--使用循环控制
---------------------------------------------
declare
   courserec SALARY%rowtype;
   counter  number:=0;
  begin
    courserec.empsal:=&id;
    courserec.empcode:='&name';
  while counter <12
   loop
      insert into SALARY
      values(courserec.empsal,courserec.empcode);
      counter:=counter+1;
      courserec.empsal:=courserec.empsal+1;
    end loop;
  end;

-----------------------------------------------
使用顺序控制
-------------------------------------------
alter table salary_records add (working_days number);

select * from salary_records

declare
     workdays number;
     salary   number;
     bonus    number;
     dept     varchar2(10);
   begin
          select  working_days,empsal,deptcode into workdays,
      salary,dept from salary_records where empcode='&empid';
     IF workdays>=29 then
     
         goto calc_raise;
        else
       DBMS_OUTPUT.PUT_LINE('工作天数少于29天');
      end if;
<<calc_raise>>
    if dept='DP01' then
           bonus :=salary*0.25;
           dbms_output.put_line(bonus);
     else
           bonus :=salary*0.10;
           dbms_output.put_line(bonus);
       end if;
   end;

set serveroutput on
 /

oracle视图索引的更多相关文章

  1. oracle 序列 视图 索引 同义词

    序列 Oracle 12C 之后,Oracle 之中提供的是一种手工的自动增长列控制,而这样的控制在 Oracle 之中使用序列(对象)完成. 序列的创建: CREATE SEQUENCE 序列名称 ...

  2. Oracle学习2 视图 索引 sql编程 游标 存储过程 存储函数 触发器

    ---视图 ---视图的概念:视图就是提供一个查询的窗口,来操作数据库中的数据,不存储数据,数据在表中. ---一个由查询语句定义的虚拟表. ---查询语句创建表 create table emp a ...

  3. Oracle索引梳理系列(七)- Oracle唯一索引、普通索引及约束的关系

    版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...

  4. Oracle视图分类及各种操作讲解(超级好文)

    目录:一.视图的定义: 二.视图的作用: 三.创建视图: 1.权限 2.语法 3.1  创建简单视图   3.2  创建连接视图  3.2.1 连接视图定义  3.2.2 创建连接视图  3.2.3 ...

  5. oracle视图总结

    视图简介: 视图是基于一个表或多个表或视图的逻辑表,本身不包含数据,通过它可以对表里面的数据进行查询和修改.视图基于的表称为基表.视图是存储在数据字典里的一条select语句. 通过创建视图可以提取数 ...

  6. oracle视图总结(转)

    视图简介: 视图是基于一个表或多个表或视图的逻辑表,本身不包含数据,通过它可以对表里面的数据进行查询和修改.视图基于的表称为基表.视图是存储在数据字典里的一条select语句. 通过创建视图可以提取数 ...

  7. oracle 创建索引思考(转)

    在Oracle数据库中,创建索引虽然比较简单.但是要合理的创建索引则比较困难了. 笔者认为,在创建索引时要做到三个适当,即在适当的表上.适当的列上创建适当数量的索引.虽然这可以通过一句话来概括优化的索 ...

  8. Oracle 视图 (待更新, 缓存)

    参考: 视图.索引.存储过程优缺点: http://www.cnblogs.com/SanMaoSpace/p/3147059.html oracle视图总结(转):http://tianwei013 ...

  9. oracle唯一索引与普通索引的区别和联系以及using index用法

    oracle唯一索引与普通索引的区别和联系 区别:唯一索引unique index和一般索引normal index最大的差异是在索引列上增加一层唯一约束.添加唯一索引的数据列可以为空,但是只要尊在数 ...

随机推荐

  1. too many automatic redirections were attempted

    用HttpClient时发现一下页面跳转现象. 页面A要求授权自动跳转到页面B, 页面B进行了授权,在HTTP Header里要求SetCookie并跳转到页面A. 再次请求页面A的时候没有带上此Co ...

  2. UVa532 Dungeon Master 三维迷宫

        学习点: scanf可以自动过滤空行 搜索时要先判断是否越界(L R C),再判断其他条件是否满足 bfs搜索时可以在入口处(push时)判断是否达到目标,也可以在出口处(pop时)   #i ...

  3. Hadoop对小文件的解决方式

    小文件指的是那些size比HDFS的block size(默认64M)小的多的文件.不论什么一个文件,文件夹和block,在HDFS中都会被表示为一个object存储在namenode的内存中, 每一 ...

  4. pod install warning

    warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 解决方法: sudo chmod 775 /usr/l ...

  5. Uestc_suibian 暑假集训总结

    唉,终于组队了,终于可以只BB了,我就BB,我就不上! 和Xiper以及chenxh组队了- 下面是总结: day1 第一天吃饱喝足,然后就上路了,我一开始就看到了C题大水题,但是我不敢想象这道题居然 ...

  6. Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子

    Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子 procedure TForm1.Button1Click(Sender: TObject); ...

  7. Android源代码下载方法具体解释

    作者:张星 相信非常多下载过内核的人都对这个非常熟悉 git clone git://android.git.kernel.org/kernel/common.git kernel 可是这是在曾经,如 ...

  8. 网络IPC:套接字之套接字描述符

    套接字是通信端点的抽象.与应用程序要使用文件描述符访问文件一样,访问套接字也需要套接字描述符.套接字描述符在UNIX系统是用文件描述符实现的.事实上,许多处理文件描述符的函数(如read和write) ...

  9. 使用C#通过Thrift访问HBase

    前言 因为项目需要要为客户程序提供C#.Net的HBase访问接口,而HBase并没有提供原生的.Net客户端接口,可以通过启动HBase的Thrift服务来提供多语言支持. Thrift介绍 环境 ...

  10. Magical Forest

    Problem Description There is a forest can be seen as N * M grid. In this forest, there is some magic ...