KingbaseES 内置了对于insert all / first 语法的支持。

一、数据准备

create table t1(product_id number, product_name varchar2(80),month number);
create table t2(product_id number, product_name varchar2(80),month number);
create table t3(product_id number, product_name varchar2(80),month number);
create table t4(product_id number, product_name varchar2(80),month number);
create table t5(product_id number, product_name varchar2(80),month number); insert into t1 values(111, 'apple',1);
insert into t1 values(222, 'orange',1);
insert into t1 values(333, 'banana',1); insert all
into t2 values (product_id, product_name,month)
into t2 values (product_id, product_name,month+1)
into t2 values (product_id, product_name,month+2)
into t2 values (product_id, product_name,month+3)
select product_id, product_name, month from t1; test=# select * from t1;
product_id | product_name | month
------------+--------------+-------
111 | apple | 1
222 | orange | 1
333 | banana | 1
(3 rows) test=# select * from t2;
product_id | product_name | month
------------+--------------+-------
111 | apple | 1
222 | orange | 1
333 | banana | 1
111 | apple | 2
222 | orange | 2
333 | banana | 2
111 | apple | 3
222 | orange | 3
333 | banana | 3
111 | apple | 4
222 | orange | 4
333 | banana | 4
(12 rows)

二、insert all

insert all
when month=1 then into t3
when month=2 then into t4
else into t5
select product_id,product_name,month from t2; test=# select * from t3;
product_id | product_name | month
------------+--------------+-------
111 | apple | 1
222 | orange | 1
333 | banana | 1
(3 rows) test=# select * from t4;
product_id | product_name | month
------------+--------------+-------
111 | apple | 2
222 | orange | 2
333 | banana | 2
(3 rows) test=# select * from t5;
product_id | product_name | month
------------+--------------+-------
111 | apple | 3
222 | orange | 3
333 | banana | 3
111 | apple | 4
222 | orange | 4
333 | banana | 4
(6 rows)

三、insert first

truncate table t3;
truncate table t4;
truncate table t5; insert first
when month<2 then into t3 values(product_id,product_name,month)
when month<3 then into t4 values(product_id,product_name,month)
else into t5 values(product_id,product_name,month)
select product_id,product_name,month from t2; test=# select * from t3;
product_id | product_name | month
------------+--------------+-------
111 | apple | 1
222 | orange | 1
333 | banana | 1
(3 rows) test=# select * from t4;
product_id | product_name | month
------------+--------------+-------
111 | apple | 2
222 | orange | 2
333 | banana | 2
(3 rows) test=# select * from t5;
product_id | product_name | month
------------+--------------+-------
111 | apple | 3
222 | orange | 3
333 | banana | 3
111 | apple | 4
222 | orange | 4
333 | banana | 4
(6 rows)

四、总结

insert first 当数据满足第一when 条件的时候,不会作用在下面的when条件了,简而言之:当一条数据满足条件后,即使满足后面的条件也不会插入数据库。如果数据满足所有的when条件,insert all每个表都会插入该条数据,insert first 数据只会插入一个表。

KingbaseES insert all/first 功能介绍的更多相关文章

  1. python中列表、元组、字典内部功能介绍

    一.列表(list) 常用功能的介绍:

  2. QTP的基本功能介绍

    • QTP的基本功能介绍 HP QuickTest Professional 支持功能測试和回归測试自己主动化,用于每一个主要软件应用程序和环境.此解决方式使用keyword驱动的測试概念,简化了測试 ...

  3. Python中list的功能介绍

    List的功能介绍 1. 列表的两种方法 1. 列表的内置方法 列表的相加 格式:x.__add__(y)等同于x+y 例如:list1 = [1,2,3] print(list1.__add__([ ...

  4. MySQL二进制日志功能介绍

    二进制日志记录所有更新数据的SQL语句,其中也包含可能更新数据的SQL语句,例如DELETE语句执行过程中无匹配的行.二进制日志中还包含了与执行SQL语句相关的内容,例如SQL语句执行的时间.错误代码 ...

  5. .NET平台开源项目速览(13)机器学习组件Accord.NET框架功能介绍

    Accord.NET Framework是在AForge.NET项目的基础上封装和进一步开发而来.因为AForge.NET更注重与一些底层和广度,而Accord.NET Framework更注重与机器 ...

  6. 微信小程序产品定位及功能介绍

    产品定位及功能介绍 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验. 小程序注册 注册小程序帐号 在微信公众平台官网首页(mp.weixin.qq ...

  7. 带你走近AngularJS - 基本功能介绍

    带你走近AngularJS系列: 带你走近AngularJS - 基本功能介绍 带你走近AngularJS - 体验指令实例 带你走近AngularJS - 创建自定义指令 ------------- ...

  8. MWeb 1.4 新功能介绍一:引入文件夹到 MWeb 中管理,支持 Octpress、Jekyll 等静态博客拖拽插入图片和实时预览

    之前在 MWeb 中打开非文档库中的 Markdown 文档,如果文档中有引用到本机图片,是没办法在 MWeb 中显示出来和预览的.这是因为 Apple 规定在 Mac App Store(MAS) ...

  9. Joomla软件功能介绍与开源程序大比拼Joomla,wordpress,Drupal哪个好?

    Joomla 软件功能介绍:    Joomla!是一套在国外相当知名的内容管理系统 (Content Management System, CMS),它属于Portal(企业入口网站)类型,顾名思义 ...

随机推荐

  1. 4种方法教你如何查看java对象所占内存大小

    摘要:本文讲述4种查看java对象所占内存大小的方法 本文分享自华为云社区<查看java对象所占内存大小>,作者:xiewenci. 计算java对象所占内存大小 1.使用jdk8自带AP ...

  2. python小题目练习(十二)

    题目:如下图所示 代码展示: """Author:mllContent:春节集五福Date:2020-01-17"""import rand ...

  3. 不存在的!python说不给数据的浏览器是不存在的!

    有时候我们些代码是总发此疑惑? 为什么别人采集 xx 网站的时候能成功,而我却总是不返回给数据出现这种原因时往往是我们没有给够伪装, 被识别了出来~ 就像人,你出门肯定是要穿衣服的对不,如果你不穿! ...

  4. 利用websocket实现手机扫码登陆后,同步登陆信息到web端页面

    新手必看 广播系统 事件系统 准备工作 初始化项目 引入 laravel-websockets 软件包 启动 websocket 监听 主要流程 创建两个页面 建立 socket 连接 手机端扫码登陆 ...

  5. 静态同步方法和解决线程安全问题_Lock锁

    静态的同步方法锁对象是谁?不能是thisthis是创建对象之后产生的,静态方法优先于对象静态方法的锁对象是本类的cLass属性-->class文件对象(反射) 卖票案例出现了线程安全问题 卖出了 ...

  6. Solution -「二项式定理与组合恒等式」一些练习

    Task 1 \(\mathcal{Prob:}\) \((3x - 2y)^{18}\) 的展开式中, \(x^5y^{13}\) 的系数是什么?\(x^8y^9\) 的系数是什么? \(\math ...

  7. PHP goto

    if (true){ echo "run if\n"; goto fly; } else{ fly: echo "run else"; }

  8. YII服务定位器依赖注入

    <?php /** * Created by PhpStorm. * Date: 2016/5/25 * Time: 18:33 * 服务定位器依赖注入 */ namespace fronten ...

  9. 使用Python3.7+Tornado5.1配合七牛云存储api来异步切分上传文件

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_123 之前写了几篇关于FastDfs分布式存储的文章:python3.7.3操作FastDfs来进行文件操作,其实市面上关于云存储 ...

  10. 3.联合索引、覆盖索引及最左匹配原则|MySQL索引学习

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 导语 在数据检索的过程中,经常会有多个列的匹配需求,今天介绍下联合索引的使用以及最左匹配原则的案例. 最左匹配原则作用在联 ...