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. Message Code 【27796】 Failed to connect to server 'hostname';port_ld': 'reason'.

    Message Code [27796] Failed to connect to server 'hostname';port_ld': 'reason'.Unable to connect to  ...

  2. Windoows窗口程序四

    子窗口的创建 .创建时要设置父窗口句柄 .创建风格要增加WS_CHILD|WS_VISIBLE HWND CreateChild(LPSTR lpClassName,LPSTR lpWndName,H ...

  3. 关于Cocos2d-x中物理世界的物体乱跳的问题的解决

    这是电脑短时间内帧率低,无法满足游戏配置的帧率引起的. 解决方法: 第一种: 1.打开AppDelegate.cpp文件 2.把director->setAnimationInterval(1. ...

  4. 【转】WCF入门教程四[WCF的配置文件]

    一.概述 配置也是WCF编程中的主要组成部分.在以往的.net应用程序中,我们会把DBConn和一些动态加载类及变量写在配置文件里.但WCF有所不同.他指定向客户端公开的服务,包括服务的地址.服务用于 ...

  5. window,centos双系统坏了

    在centos中格式化SD卡的时候,操作错误,误将windows系统C盘的给格式化了.C盘是ntf格式的,现在却变为了fat32的格式. 重启系统,发现还是可以进入到centos,但是window进入 ...

  6. 象“[]”、“.”、“->”这类操作符前后不加空格

    象“[]”.“.”.“->”这类操作符前后不加空格. #include <iostream> #include <process.h> #include<stdio ...

  7. 用C结构体来实现面向对象编程,ti xDAIS标准算法就这么搞的(1)

    用C结构体来实现面向对象编程,ti xDAIS标准算法就这么搞的. 测试代码如下: #include <stdio.h> #include <stdlib.h> #includ ...

  8. 基于Poco的UTF8、UTF16、GBK、Hex之间的转换

    /******Encoding.h*******/ #include "Poco/UnicodeConverter.h" #include "Poco/Exception ...

  9. 与其他Javascript类库冲突解决方案

    $(document).ready(function() { var $jq = jQuery.noConflict(); $jq('#id').show(); });

  10. jquery.attach附件上传jquery插件

    html: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta http-equiv=&qu ...