INSERT

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‘, ‘[email protected]‘,
       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;
时间: 2024-10-10 04:43:21

INSERT的相关文章

专利事务所信息Python爬取

数据来源:http://www.acpaa.cn/ 目前事务所的信息没有做反爬限制,还是很容易拿到数据的 没有用html解析工具,直接上正则,结果就是需要处理很多乱七八糟的空格...为了能将日期顺利的插入到数据库,做了很多转换.这个代码没用多线程. 下面是代码,Python版本为3.5,需要安装pymsql,mysql # -*- coding: UTF-8 -*- import http.client import re import pymysql def saveAgency(code,

【Leetcode】Insert Delete GetRandom O(1) - Duplicates allowed

题目链接:https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/ 题目: Design a data structure that supports all following operations in average O(1) time. Note: Duplicate elements are allowed. insert(val): Inserts an item val to the c

Bulk Insert Syntax

BULK INSERT Imports a data file into a database table or view in a user-specified format. BULK INSERT [ database_name . [ schema_name ] . | schema_name . ] [ table_name | view_name ] FROM 'data_file' [ WITH ( [ [ , ] BATCHSIZE = batch_size ] [ [ , ]

实战c++中的vector系列--再谈vector的insert()方法(都是make_move_iterator惹的祸)

之前说过了关于vector的insert()方法,把vector B的元素插入到vector A中,vector A中的结果我们可想而知,但是vector B中的元素还会如何? 看看之前写过的程序: #include <iostream> #include <vector> int main () { std::vector<int> myvector (3,100); std::vector<int>::iterator it; it = myvector

LeetCode Insert Interval

原题链接在这里:https://leetcode.com/problems/insert-interval/ AC Java: 1 /** 2 * Definition for an interval. 3 * public class Interval { 4 * int start; 5 * int end; 6 * Interval() { start = 0; end = 0; } 7 * Interval(int s, int e) { start = s; end = e; } 8

Java MongoDB insert

public class  Foo implements IdObject { public String id;    public String firstName;    private String lastName;        @Override     String getId() {        return id;    }        @Override    public void toDocument(Document doc) {        doc.appen

【MongoDB学习笔记6】深入MongoDB的创建/插入(insert)

简单单个文档插入用insert方法: > db.post.insert({"bar":"baz"});     WriteResult({ "nInserted" : 1 }) 批量插入,用insert方法(参数要是一个文档数组): > db.post.insert([{"_id":0},{"_id":1},{"_id":2}]);    BulkWriteResult({ 

【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update

1, Insert MongoDB is database storing document object, the type of which is called Bson.(like JSON); Example:  // document defination Now after using command[db.posts.insert(doc)], you will insert record successfully if seeing the The following pictu

veridata实验举例(3)验证veridata查找出insert操作导致的不同步现象

veridata实验举例(3)验证veridata查找出insert操作导致的不同步现象 续接:<veridata实验举例(2)验证表BONUS与表SALGRADE两节点同步情况>,地址:点击打开链接 环境: Item Source System Target System Platform Red Hat Enterprise Linux Server release 5.4 Red Hat Enterprise Linux Server release 5.4 Hostname gc1 g

mongodb3.2系统性学习——1、文档插入insert insertOne insertMany

写操作——添加操作 mongodb提供以下操作执行添加文档操作 db.collection.insertOne() 3.2新添加 db.collection.insertMany() 3.2 新添加 db.collection.insert() 首先介绍下 insertone() 操作 语法规则: db.collection.insertOne( <document>, { writeConcern: <document> //Optional. A document expres