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(企业入口网站)类型,顾名思义 ...
随机推荐
- Day05 表格
表格 <table width="300" border="1" cellspacing="0"> <caption> ...
- Pytorch从0开始实现YOLO V3指南 part1——理解YOLO的工作
本教程翻译自https://blog.paperspace.com/how-to-implement-a-yolo-object-detector-in-pytorch/ 视频展示:https://w ...
- Math类和函数定义
Math这个类是java系统内部当中的一个类,他用来提供一些基本的数学操作,他也有些工具可以给我们用比如 :abs--算绝对值 pow--算幂次 random--随机数 round--四舍 ...
- 洛谷 P1714 切蛋糕 单调队列
这个题比较显然,要用前缀和来做.但只用前缀和是过不去的,会TLE,所以需要进行优化. 对于每个前缀和数组 b 中的元素,都可以找到以 b[i] 结尾的子段最大值 p[i],显然,最终的 ans 就是 ...
- Harbor-私有镜像仓库的安装部署
Harbor 安装条件 官网给出了安装需要的最低硬件和软件的条件:https://goharbor.io/docs/2.0.0/install-config/installation-prereqs/ ...
- Aborted wiping of zfs_member.1 existing signature left on the device.Aborting pvcreate on /dev/sda
看意思是有什么签名在上面,创建不了逻辑卷,确认数据备份的情况下执行对应的下面命令: wipefs --all --force /dev/sdax
- 实践GoF的23种设计模式:观察者模式
摘要:当你需要监听某个状态的变更,且在状态变更时通知到监听者,用观察者模式吧. 本文分享自华为云社区<[Go实现]实践GoF的23种设计模式:观察者模式>,作者: 元闰子 . 简介 现在有 ...
- linux学习系列--初识Linux系统
### 认识Linux- Linux是一种类UNIX的系统,Unix是1965年在贝尔实验室开发的一个项目,用来开发操作系统- Linux之父-Linus Torvalds在1991年10月5日,他在 ...
- Nginx listen、server_name、location的配置
# Nginx静态资源的配置指令 # listen指令 # 语法 listen address[:port][default_server] # 如: listen 127.0.0.1:8000: # ...
- 5.31 NOI 模拟
\(T1\ Beauty\) \(T2\ Jump\) 考场上一开始想的是树套树,然后我看到了\(128MB,\)好 于是乎附上\(56pts\ MLE\)代码在空间\(512MB\)可以获得\(84 ...