INSERT INTO departments
VALUES (departments_seq.nextval, 'Entertainment', 162, 1400);
INSERT INTO employees
(employee_id, last_name, email, hire_date, job_id, salary)
VALUES
(employees_seq.nextval, 'Doe', 'john.doe@example.com',
SYSDATE, 'SH_CLERK', 2400)
RETURNING salary*12, job_id INTO :bnd1, :bnd2;

ALL

If you specify ALL, the default value, then the database evaluates each WHEN clause regardless of the results of the evaluation of any other WHEN clause. For each WHEN clause whose condition evaluates to true, the database executes the corresponding INTO clause list.

FIRST

If you specify FIRST, then the database evaluates each WHEN clause in the order in which it appears in the statement. For the first WHEN clause that evaluates to true, the database executes the corresponding INTO clause and skips subsequent WHEN clauses for the given row.

CREATE TABLE small_orders
(order_id NUMBER(12) NOT NULL,
customer_id NUMBER(6) NOT NULL,
order_total NUMBER(8,2),
sales_rep_id NUMBER(6)
); CREATE TABLE medium_orders AS SELECT * FROM small_orders; CREATE TABLE large_orders AS SELECT * FROM small_orders; CREATE TABLE special_orders
(order_id NUMBER(12) NOT NULL,
customer_id NUMBER(6) NOT NULL,
order_total NUMBER(8,2),
sales_rep_id NUMBER(6),
credit_limit NUMBER(9,2),
cust_email VARCHAR2(30)
); Puts orders greater than 290,000 into thespecial_orders table.
INSERT ALL
WHEN ottl <= 100000 THEN
INTO small_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 100000 and ottl <= 200000 THEN
INTO medium_orders
VALUES(oid, ottl, sid, cid)
   WHEN ottl > 200000 THEN
      into large_orders  --不仅存放大于200000的数据,而且存放大于290000的数据
          VALUES(oid, ottl, sid, cid)
   WHEN ottl > 290000 THEN
      INTO special_orders  --仅存放大于290000的数据
   SELECT o.order_id oid,
    o.customer_id cid,
          o.order_total ottl,
          o.sales_rep_id sid,
        c.credit_limit cl,
        c.cust_email cem
      FROM orders o, customers c
      WHERE o.customer_id = c.customer_id; put orders greater than 200,000 into the large_orders table andspecial_orders table is null:
INSERT FIRST
WHEN ottl <= 100000 THEN
INTO small_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 100000 and ottl <= 200000 THEN
INTO medium_orders
VALUES(oid, ottl, sid, cid)
   WHEN ottl > 200000 THEN
      into large_orders  --不仅存放大于200000的数据,而且存放大于290000的数据
          VALUES(oid, ottl, sid, cid)
   WHEN ottl > 290000 THEN
      INTO special_orders  --没有大于290000的数据,此表为空
   SELECT o.order_id oid,
          o.customer_id  cid,
          o.order_total  ottl,
          o.sales_rep_id sid,
          c.credit_limit cl,
          c.cust_email   cem
      FROM orders o, customers c
      WHERE o.customer_id = c.customer_id;

INSERT高级应用的更多相关文章

  1. 插入数据:insert,replace

    *insert高级用法* 1.语法:insert into tbname(字段列表) values 值列表; 1.1可以不将所有的字段都插入数据.如果说需要完成部分字段的插入,需要必须存在字段列表. ...

  2. 排序算法 -- 数据结构与算法的javascript描述 第12章

    排序是常见的功能,给定一组数据,对其进行排序. 在此之前,我们需要准备个基础工作--自动生成数组,并可以对该组数据做任何处理. /** * 测试类 ,数组 * @param numElements * ...

  3. Mybatis详解系列(一)--持久层框架解决了什么及如何使用Mybatis

    简介 Mybatis 是一个持久层框架,它对 JDBC 进行了高级封装,使我们的代码中不会出现任何的 JDBC 代码,另外,它还通过 xml 或注解的方式将 sql 从 DAO/Repository ...

  4. 省市区三级-sql脚本:

    /*Navicat MySQL Data Transfer Source Server : moiraiSource Server Version : 50631Source Host : 192.1 ...

  5. oracle数据库高级应用之《自动生成指定表的insert,update,delete语句》

    /* * 多条记录连接成一条 * tableName 表名 * type 类型:可以是insert/update/select之一 */ create or replace function my_c ...

  6. MongoDB高级查询详细

    前言 前几篇,老玩家绕道即可,新手晚上闲着也是蛋疼,不如把命令敲一边,这样你就会对MongoDB有一定的掌握啦.如果没有安装MongoDB去看我的上一篇博客  MongoDB下载安装与简单增删改查 前 ...

  7. Python09作业思路及源码:高级FTP服务器开发(仅供参考)

    高级FTP服务器开发 一,作业要求 高级FTP服务器开发 用户加密认证(完成) 多用户同时登陆(完成) 每个用户有不同家目录且只能访问自己的家目录(完成) 对用户进行磁盘配额,不同用户配额可不同(完成 ...

  8. 一个高级的J2E工程师需要面对MySQL要有那些基本功夫呢<上>

    1. MySQL的架构介绍1.1 MySQL简介: MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL是一种关联数据库管理系统,将数据保存在不 ...

  9. MySQL高级特性

    MySQL管理 用户管理 CREATE USER username IDENTIFIED BY 'password'; 新建用户 CREATE USER@'%' IDENTIFIED BY 'pass ...

随机推荐

  1. Jquery实现仿腾讯微薄的广播发表

    前言: 由于这几天在学习Jquery的一些知识,比以前的感觉就是Jquery太强大了,很多很简单的功能以前在JavaScript要写几十行的代码而在Jquery中只用几行代码就搞定了,所以我决定好好学 ...

  2. WebForm和MVC的一些知识(转)

    转自:http://www.cnblogs.com/liuhf939/p/3417203.html 比较WebForm和Mvc的请求处理方式 首先简单了解一下Asp.Net中怎么对页面进行请求处理的: ...

  3. latex之转置符号

    $\mathbf{A}^\mathrm{T}$ $\mathbf{A}^\top$ $\mathbf{A}^\mathsf{T}$ $\mathbf{A}^\intercal$ 效果分别为:

  4. imx6 android power off

    调试android4.2的关机功能,希望再按下power按键长时间之后就关机.不弹出选框. 参考链接 http://www.cnblogs.com/sardine/archive/2011/07/26 ...

  5. 利用base64展示图片

    其实很简单,格式如下: <img src="data:image/jpg;base64,具体的编码值" /> 支持的类型有: data:,文本数据 data:text/ ...

  6. Java 关于finally、static

    论坛上看到的两道题目,如下: //为啥运行结果是1 0 不是 0 0呢 谁能解释下啊 public class FinallyDemo { static int value = 0; static i ...

  7. 【Java面试题】33 HashMap和Hashtable的区别

    1 HashMap不是线程安全的 hastmap是一个接口 是map接口的子接口,是将键映射到值的对象,其中键和值都是对象,并且不能包含重复键,但可以包含重复值.HashMap允许null key和n ...

  8. php对gzip的使用(开启)

    gzip是一种压缩算法,在网络通信过程中,经常用到gzip压缩算法.比如一个文本文件,大小为100M,使用gzip压缩之后,大小可能会变成几M.在网络传输过程中,传10M和传100M,消耗的时间和带宽 ...

  9. php一些常规动态设置与获取

    error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE);ini ...

  10. c++ json cpp

    一 编译链接 1 在相应官网下载jsoncpp 2 解压得到jsoncpp-src-0.5.0文件 3 打开jsoncpp-src-0.5.0 -> makefiles -> vs71 - ...