当前位置:网站首页>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
边栏推荐
- PAHO cross compilation
- Docker安装Redis、配置及远程连接
- Object storage
- 二次握手??三次挥手??
- 【日志框架】
- Shell notes (super complete)
- 这才是开发者神器正确的打开方式
- Reasons for the rise of DDD and its relationship with microservices
- Correct posture and landing practice of R & D efficiency measurement (speech ppt sharing version)
- Notes for Resume Writing
猜你喜欢

为什么要使用markdown进行写作?

Consumer electronics, frozen to death in summer

Second handshake?? Three waves??

静态资源映射

Follow teacher Tian to learn practical English Grammar (continuous update)

关系型数据库之MySQL8——由内而外的深化全面学习

SAP Fiori @OData. Analysis of the working principle of publish annotation
![[jetson][reprint]pycharm installed on Jetson](/img/65/ba7f1e7bd1b39cd67018e3f17d465b.png)
[jetson][reprint]pycharm installed on Jetson

Efficient 7 habit learning notes

不堆概念、换个角度聊多线程并发编程
随机推荐
How big is the bandwidth of the Tiktok server for hundreds of millions of people to brush at the same time?
云服务大厂高管大变阵:技术派让位销售派
ECCV 2022 | CMU proposes to recurse on the visual transformer without adding parameters, and the amount of calculation is still small
Modulenotfounderror: no module named 'pywt' solution
After eating Alibaba's core notes of highly concurrent programming, the backhand rose 5K
跟着李老师学线代——行列式(持续更新)
VMWare:使用命令更新或升级 VMWare ESXi 主机
2022cuda summer training camp Day1 practice
敏捷开发如何消减协作中的认知偏差?| 敏捷之道
[FPGA tutorial case 19] factorial operation through multiplier
[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
Evolution of xxl-job architecture for distributed scheduling
通俗易懂讲解梯度下降法!
Hanyuan high tech Gigabit 2-optical 6-conductor rail managed Industrial Ethernet switch supports X-ring redundant ring network one key ring network switch
R 语言 二分法与 牛顿迭代法计算中方程的根
Implementation of college logistics repair application system based on SSM
二次握手??三次挥手??
2022cuda summer training camp day3 practice
Error: Protobuf syntax version should be first thing in file
Is there any charge for PDF processing? impossible