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(企业入口网站)类型,顾名思义 ...
随机推荐
- C#判断数组或集合中是否含有属性值为value的对象
/// <summary> /// 判断list中是否有某个对象的Id_srvplan为value /// </summary> /// <param name=&quo ...
- 一条 SQL 语句是如何执行的
一条 SQL 语句是如何执行的 SQL查询语句 select * from user where ID=10; MySQL 的基本架构可以分为 Server 层和存储引擎两部分.Server 层又包含 ...
- ansible管理windows主机
1. 在windows开启winrm winrm service 默认都是未启用的状态,先查看状态:如无返回信息,则是没有启动: winrm enumerate winrm/config/listen ...
- 几百行代码实现一个 JSON 解析器
前言 之前在写 gscript时我就在想有没有利用编译原理实现一个更实际工具?毕竟真写一个语言的难度不低,并且也很难真的应用起来. 一次无意间看到有人提起 JSON 解析器,这类工具充斥着我们的日常开 ...
- Windows 通过本地计算机IP链接Mysql设置
前言 1.Mysql-1130错误:无法远程连接 错误:ERROR 1130: Host '192.168.1.3' is not allowed to connect to thisMySQL se ...
- java请求登录接口代码示例
前言 近期研究如何利用java代码如何获取其他系统中所需的数据,自己总结的方法如下: 1.工具类代码 /** * <pre> * 方法体说明:向远程接口发起请求,返回字符串类型结果 * @ ...
- 卸载office密钥
一.管理员身份运行命令提示行: 二.命令提示行上输入: cd C:\Program Files\Microsoft Office\Office16 弹出如下内容: C:\Program Files\M ...
- [ZJCTF 2019]NiZhuanSiWei 1
考察知识点:反序列化.php伪协议 1.打开之后获得源码信息,如下: <?php $text = $_GET["text"]; $file = $_GET["fil ...
- ORM框架介绍——什么是ORM框架?
1.什么是ORM?对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术.ORM框架是连接数据库的桥梁,只要提供 ...
- 记一次 .NET 某RFID标签管理系统 CPU 暴涨分析
一:背景 1. 讲故事 前段时间有位朋友说他的程序 CPU 出现了暴涨现象,由于程序是买来的,所以问题就比较棘手了,那既然找到我,就想办法帮朋友找出来吧,分析下来,问题比较经典,有必要和大家做一下分享 ...