KingbaseES insert all/first 功能介绍
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 功能介绍的更多相关文章
- python中列表、元组、字典内部功能介绍
一.列表(list) 常用功能的介绍:
- QTP的基本功能介绍
• QTP的基本功能介绍 HP QuickTest Professional 支持功能測试和回归測试自己主动化,用于每一个主要软件应用程序和环境.此解决方式使用keyword驱动的測试概念,简化了測试 ...
- Python中list的功能介绍
List的功能介绍 1. 列表的两种方法 1. 列表的内置方法 列表的相加 格式:x.__add__(y)等同于x+y 例如:list1 = [1,2,3] print(list1.__add__([ ...
- MySQL二进制日志功能介绍
二进制日志记录所有更新数据的SQL语句,其中也包含可能更新数据的SQL语句,例如DELETE语句执行过程中无匹配的行.二进制日志中还包含了与执行SQL语句相关的内容,例如SQL语句执行的时间.错误代码 ...
- .NET平台开源项目速览(13)机器学习组件Accord.NET框架功能介绍
Accord.NET Framework是在AForge.NET项目的基础上封装和进一步开发而来.因为AForge.NET更注重与一些底层和广度,而Accord.NET Framework更注重与机器 ...
- 微信小程序产品定位及功能介绍
产品定位及功能介绍 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验. 小程序注册 注册小程序帐号 在微信公众平台官网首页(mp.weixin.qq ...
- 带你走近AngularJS - 基本功能介绍
带你走近AngularJS系列: 带你走近AngularJS - 基本功能介绍 带你走近AngularJS - 体验指令实例 带你走近AngularJS - 创建自定义指令 ------------- ...
- MWeb 1.4 新功能介绍一:引入文件夹到 MWeb 中管理,支持 Octpress、Jekyll 等静态博客拖拽插入图片和实时预览
之前在 MWeb 中打开非文档库中的 Markdown 文档,如果文档中有引用到本机图片,是没办法在 MWeb 中显示出来和预览的.这是因为 Apple 规定在 Mac App Store(MAS) ...
- Joomla软件功能介绍与开源程序大比拼Joomla,wordpress,Drupal哪个好?
Joomla 软件功能介绍: Joomla!是一套在国外相当知名的内容管理系统 (Content Management System, CMS),它属于Portal(企业入口网站)类型,顾名思义 ...
随机推荐
- 安装pystaller
安装命令 # -i指定下载地址,此处采用清华大学镜像 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package pyin ...
- 数字格式化的 js 库
数字格式化的 js 库 Numeral.js,是一个用于格式化数字和处理数字的 js 库. Tip:目前 Star 有 9.2k,5年以前就没有在更新.其文档写得不很清晰,比如它提供了多语言,但如何切 ...
- expect自动应答
expect脚本 1. expect简介 expect是一个用来处理交互的命令.借助Expect,我们可以将交互过程写在一个脚本上,使之自动化完成. expect(自动应答) 基于TCL(Tool C ...
- Halcon · 曲线宽度检测算法总结
视觉检测中,直线的宽度很好检测,即两条平行线的垂直距离,而曲线的宽度检测则需要另辟蹊径. 检测图像中曲线边缘的宽度,用以判断边缘是否崩缺,总结如下五种方法: 1.图像匹配判断 概述:建立标准图像参考, ...
- css-sticky 定位
前言 我们大多都了解绝对定位.相对定位.static 和 fixed 定位,而 sticky 定位常常会被忽略,本文来总结一下其相关使用方法. 正文 1.常见使用效果 我们滚动滚动条时,当 " ...
- Cf #782 (Div. 2)
A. Red Versus Blue 题意 共有 n 个连续字符 ,其中有 a 个 R ,b 个 B (a+b=n),问怎么排列使 R 的最大连续个数最小,输出一种可能排列 思路 b 个B可以把a个 ...
- 在矩池云使用Disco Diffusion生成AI艺术图
在 Disco Diffusion 官方说明的第一段,其对自身是这样定义: AI Image generating technique called CLIP-Guided Diffusion.DD ...
- Linux为所有用户安装Miniconda
如果以root身份默认安装,后续普通用户再安装的话,是直接用不起来的,需要改些东西,所以在安装时最好全局安装,所有用户都可用 执行安装脚本:sudo bash Miniconda3-latest-Li ...
- web 前端 基础HTML知识点
web系统架构体系 B/S(Browser/Server):浏览器实现 优点: 规范.使用方便.本身实现成本低 容易升级.便于维护 缺点: 没有网络,无法使用 保存数据量有限,和服务器交互频率高.耗费 ...
- 浅谈spring-createBean
目录 找到BeanClass并且加载类 实例化前 实例化 Supplier创建对象 工厂方法创建对象 方法一 方法二 推断构造方法 BeanDefionition 的后置处理 实例化后 属性填充 sp ...