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(企业入口网站)类型,顾名思义 ...
随机推荐
- 你真的了解git的分支管理跟其他概念吗?
现在前端要学的只是太多了,你是不是有时会有这个想法,如果我有两个大脑.一个学Vue,一个学React,然后到最后把两个大脑学的知识再合并在一起,这样就能省时间了. 哈哈,这个好像不能实现.现实点吧!年 ...
- Leetcode--Last Stone Weight II
Last Stone Weight II 欢迎关注H寻梦人公众号 You are given an array of integers stones where stones[i] is the we ...
- NC20565 [SCOI2009]生日礼物
NC20565 [SCOI2009]生日礼物 题目 题目描述 小西有一条很长的彩带,彩带上挂着各式各样的彩珠.已知彩珠有 \(N\) 个,分为 \(K\) 种.简单的说,可以将彩带考虑为 \(x\) ...
- HTTP Status 405 - Request method 'GET' not supported?(尚硅谷Restful案例练习关于Delete方法出现的错误)
哈罗大家好,最近在如火如荼的学习java开发----Spring系列框架,当学习到SpringMVC,动手实践RESTFUL案例时,发现了以上报错405,get请求方法没有被支持. 首先第一步,我查看 ...
- Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
https://www.bilibili.com/video/BV1tT411g7PA/?aid=470724972&cid=766317673&page=1 点击上方链接,一分钟快速 ...
- Mysql性能调优-工具篇
EXPLAIN 首先祭出官方文档(这是5.7的,请自行选择版本): Understanding the Query Execution Plan 英文不想看,就看这篇吧: 全网最全 | MySQL E ...
- MD5,Des,RSA加密解密
一.加密和解密 下面先熟悉几个概念 1>对称加密:加密的key和解密的key是同一个 但是如何确保密钥安全地进行传递?秘钥的安全是一个问题 2>非对称加密:加密点的key和解密的key不是 ...
- SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
感谢各位大佬和粉丝的厚爱和关心( 催更),我会再接再厉的,其实这也是督促自己的一种方式,非常感谢. 刚写了一篇万字长文,自己也休养生息(低调发育)了一段时间,接下来来几个小案例. 拖曳小球 WPF的拖 ...
- Windows高效开发环境配置(一)
更多精彩内容,欢迎关注公众号:逻魔代码 前言 用了多年的 MacOS 做开发,一系列诸如 Alfred.Item2.Oh-my-zsh 之类的工具,大大地提升了工作的效率和使用舒适度.新工作不给配 M ...
- 一网成擒全端涵盖,在不同架构(Intel x86/Apple m1 silicon)不同开发平台(Win10/Win11/Mac/Ubuntu)上安装配置Python3.10开发环境
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_200 时光荏苒,过隙白驹,即将进入2022年,著名敏捷开发语言Python也放出了3.10最终版,本次我们来展示一下在不同的系统和 ...