当前位置:网站首页>Kunlunbase support for MySQL private DML syntax
Kunlunbase support for MySQL private DML syntax
2022-07-29 10:31:00 【InfoQ】
Preface
One 、 compatible MySQL Of insert ignore grammar
postgres -> create table t1(a int primary key, b int not null unique);
CREATE TABLE
# Violate the only constraint , No insertion
postgres -> insert ignore into t1(a,b) values (4,4);
INSERT 0 1
postgres -> insert ignore into t1(a,b) values (4,4);
INSERT 0 0
- Only the uniqueness constraint is ignored , If other constraints are violated ( For example, partition constraints 、 Not null constraint ), False report .
postgres -> insert ignore into t1(a,b) values (4,NULL);
ERROR: null value in column "b" violates not-null constraint
DETAIL: Failing row contains (4, null)
Two 、 compatible MySQL Of INSERT...ONDUPLICATE KEY UPDATE... grammar
postgres -> create table t1 (a int primary key, b int not null unique);
CREATE TABLE
postgres -> insert into t1 values(3,3), (4,4);
INSERT 0 2
# The inserted data conflicts with the two existing tuples , But only one tuple was updated (3,3)
postgres -> insert into t1 values(3,4) on duplicate key update b=2;
INSERT 0 2
postgres -> select * from t1;
a | b
---+---
3 | 2
4 | 4
- Temporarily not supported in ON DUPLICATE KEY UPDATE Used in clauses VALUES() Function to reference the new value , have access to excluded Virtual table instead .
postgres -> INSERT INTO t1 VALUES(3,0) ON DUPLICATE KEY UPDATE b = excluded.b;
INSERT 0 2
postgres -> select * from t1;
a | b
---+---
3 | 0
4 | 4
(2rows)
postgres -> INSERT INTO t1 VALUES(3,0) ON DUPLICATE KEY UPDATE b=VALUES(b);
ERROR: syntax error at or near "VALUES"
- When batch writing multiple new element groups to the temporary table , If there is a uniqueness conflict between new element groups , May be an error ( The root cause is that the temporary table exists in the calculation node , It's not innodb engine ).
postgres -> create temp table t1(a int primary key, b int not null unique);
CREATE TABLE
postgres -> INSERT INTO t1 VALUES(5,5), (5,6) ON DUPLICATE KEY UPDATE b = excluded.b;
ERROR: ON CONFLICT DO UPDATE command cannot affect row a secondtime
HINT: Ensure that norows proposed for insertion within the same command have duplicate constrained values.
postgres ->
- The difference in the number of rows returned by the temporary table . Even if the values before and after the update are the same , The number of affected rows returned by the temporary table is still greater than 0.
postgres -> create temp table t1(a int primary key, b int not null unique);
CREATE TABLE
postgres -> INSERT INTO t1 VALUES(5,5) ON DUPLICATE KEY UPDATE b=excluded.b;
INSERT 0 1
postgres -> INSERT INTO t1 VALUES(5,5) ON DUPLICATE KEY UPDATE b=excluded.b;
INSERT 0 1
3、 ... and 、 compatible mysql Of replace into grammar
postgres -> create table t1(a int primary key, b int not null unique);
CREATE TABLE
postgres -> insert into t1 values(3,3),(4,4);
INSERT 0 2
postgres -> replace into t1 values(3,4);
INSERT 0 3
postgres -> select * from t1;
a | b
---+---
3 | 4
(1row)
- When batch writing multiple new element groups to the temporary table , If there is a uniqueness conflict between new element groups , May be an error ( The root cause is that the temporary table exists in the calculation node , It's not innodb engine ).
postgres -> create table t1(a int primary key, b int not null unique);
CREATE TABLE
postgres -> replace into t1 values(1,1),(1,2);
INSERT 0 3
postgres -> create temp table t2(a int primary key,b int not null unique);
CREATE TABLE
postgres -> replace into t2 values(1,1),(1,2);
ERROR: REPLACEINTO command cannot affect row a secondtime
HINT: Ensure that norows proposed for insertion within the same command have duplicate constrained values.
Four 、 compatible MySQL Of update/delete...order by...limit.. grammar
postgres -> create table t1 (a int primary key, b int);
CREATE TABLE
postgres -> insert into t1 select generate_series(1,100),generate_series(1,100);
INSERT 0 100
# Orderly update of non partitioned tables
postgres -> update t1 set b=b+1 order by a desc limit 4 returning*;
a | b
-----+-----
100 | 101
99 | 100
98 | 99
97 | 98
(4rows)
UPDATE 4
postgres -> drop table t1;
DROP TABLE
postgres -> CREATE TABLE t1 (A INT PRIMARY KEY,B INT) PARTITION BY RANGE(a);
CREATE TABLE
postgres -> CREATE TABLE t1p1 PARTITION OF t1 FOR VALUES FROM (0) TO (100);
CREATE TABLE
postgres -> CREATE TABLE t1p2 PARTITION OF t1 FOR VALUES FROM (100) TO (200);
CREATE TABLE
postgres -> insert into t1 select generate_series(0,199);
INSERT 0 200
# Specifies the total amount of partition table deletion
postgres -> delete from t1 limit 4 returning *;
a | b
---+---
0 |
1 |
2 |
3 |
(4rows)
DELETE 4
- The update of the specified partition table is not supported at the moment / Order of deletion ( Be careful : Partition table of temporary table already supports ). Of course , In actual use, it is necessary to strictly regulate and update / The scenario of deleting order is very few , This restriction will not affect KunlunBase Of users .
postgres -> CREATE TABLE t1 (A INT PRIMARY KEY, B INT) PARTITION BY RANGE(a);
CREATE TABLE
postgres -> CREATE TABLE t1p1 PARTITION OF t1 FOR VALUESFROM (0) TO (100);
CREATE TABLE
postgres -> CREATE TABLE t1p2 PARTITION OF t1 FORVALUESFROM (100) TO (200);
CREATE TABLE
# Cannot specify partition table deletion order
postgres -> delete from t1 order by a limit 4 returning *;
ERROR: Kunlun-db: Cannot push down plan
postgres ->
END
边栏推荐
- Leetcode question brushing - sorting
- Only simple function test? One article takes you to advanced interface automatic testing technology in 6 steps
- factoextra:多元统计方法的可视化PCA
- [paper reading] q-bert: Hessian based ultra low precision quantification of Bert
- MySQL optimization theory study guide
- How beautiful can VIM be configured?
- Atomic operation of day4 practice in 2022cuda summer training camp
- 数据可视化设计指南(信息图表篇)
- After eating Alibaba's core notes of highly concurrent programming, the backhand rose 5K
- Create PHP message board system with kubernetes
猜你喜欢

电竞入亚后,腾讯要做下一个“NBA赛事捕手”?

跟着田老师学实用英语语法(持续更新)
![[dark horse morning post] Youxian responded to the dissolution every day, and many places have been unable to place orders; Li Bin said that Wei Lai will produce a mobile phone every year; Li Ka Shing](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] Youxian responded to the dissolution every day, and many places have been unable to place orders; Li Bin said that Wei Lai will produce a mobile phone every year; Li Ka Shing

Object storage

Research on the realization of linear gradient circular progress bar
![[semantic segmentation] 2021-pvt iccv](/img/43/3756c0dbc30fa2871dc8cae5be9bce.png)
[semantic segmentation] 2021-pvt iccv

汉源高科千兆2光6电导轨式网管型工业级以太网交换机支持X-Ring冗余环网一键环网交换机
![[HFCTF 2021 Final]easyflask](/img/58/8113cafae8aeafcb1c9ad09eefd30f.jpg)
[HFCTF 2021 Final]easyflask

Two MySQL tables with different codes (utf8, utf8mb4) are joined, resulting in index failure

Does neural network sound tall? Take you to train a network from scratch (based on MNIST)
随机推荐
主子仓库都修改,如何进行同步?
NUMA architecture CPU API change summary
“为机器立心”:朱松纯团队搭建人与机器人的价值双向对齐系统,解决人机协作领域的重大挑战
Comprehensive and detailed SQL learning guide (MySQL direction)
Data office system
二次握手??三次挥手??
Notes for Resume Writing
2022cuda summer training camp Day2 practice
数据可视化设计指南(信息图表篇)
使用tidymodels搞定二分类logistic模型
关系型数据库之MySQL8——由内而外的深化全面学习
Uniswap entered the NFT trading market and opensea took the lead
Oracle advanced (XIV) explanation of escape characters
Error: Protobuf syntax version should be first thing in file
remap_ Use of table in impdp
VMWare:使用命令更新或升级 VMWare ESXi 主机
How beautiful can VIM be configured?
This developer, who has been on the list for four consecutive weeks, has lived like a contemporary college student
Turn the evolutionary path of push
Mitsubishi PLC and Siemens PLC