PostgreSQL 11 preview - MERGE 语法支持与CTE内支持,兼容SQL:2016 , 兼容 Oracle

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介:

标签

PostgreSQL , MERGE , CTE , trigger , rule


背景

PostgreSQL 11 支持了merge 语法,兼容SQL 2016标准。并且支持用于CTE语法中。

merge 语法常用于合并数据(将 某个源表、values表达式、QUERY、临时表等 合并到某个目标表中)。

例如,将源表的变更日志,合并到物化视图中。

PostgreSQL 除了使用insert into on conflict,如今又多了merge语法的支持(可以更好的支持OLAP的数据批量合并场景)。

语法

https://www.postgresql.org/docs/devel/static/sql-merge.html

[ WITH with_query [, ...] ]  
MERGE INTO target_table_name [ [ AS ] target_alias ]  
USING data_source  
ON join_condition  
when_clause [...]  
  
where data_source is  
  
{ source_table_name |  
  ( source_query )  
}  
[ [ AS ] source_alias ]  
  
and when_clause is  
  
{ WHEN MATCHED [ AND condition ] THEN { merge_update | merge_delete } |  
  WHEN NOT MATCHED [ AND condition ] THEN { merge_insert | DO NOTHING }  
}  
  
and merge_insert is  
  
INSERT [( column_name [, ...] )]  
[ OVERRIDING { SYSTEM | USER } VALUE ]  
{ VALUES ( { expression | DEFAULT } [, ...] ) | DEFAULT VALUES }  
  
and merge_update is  
  
UPDATE SET { column_name = { expression | DEFAULT } |  
             ( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] )  
           } [, ...]  
  
and merge_delete is  
  
DELETE  

返回

MERGE total-count  

目标表触发器可能被触发

触发规则详见

https://www.postgresql.org/docs/devel/static/sql-merge.html

目标表规则不会被触发

如果JOIN过程中,匹配到多行,根据SQL标准定义来处理,目前是这样的,如果是更新的话,多行匹配(目标表的某单行,被源表或源数据的多行匹配到)会导致报错。

一些例子

1、Perform maintenance on CustomerAccounts based upon new Transactions.

MERGE INTO CustomerAccount CA  -- 目标表  
USING RecentTransactions T  -- 源可以是表、query、(values (),(),....) as alias表达式 等  
ON T.CustomerId = CA.CustomerId  -- JOIN 条件  
WHEN MATCHED THEN  -- 记录匹配,可以引用使用源于目标中的字段  
  UPDATE SET Balance = Balance + TransactionValue  
WHEN NOT MATCHED THEN  -- 记录未匹配,只能引用源字段  
  INSERT (CustomerId, Balance)  
  VALUES (T.CustomerId, T.TransactionValue);  

2、notice that this would be exactly equivalent to the following statement because the MATCHED result does not change during execution

MERGE INTO CustomerAccount CA  
USING (Select CustomerId, TransactionValue From RecentTransactions) AS T  
ON CA.CustomerId = T.CustomerId  
WHEN NOT MATCHED THEN  
  INSERT (CustomerId, Balance)  
  VALUES (T.CustomerId, T.TransactionValue)  
WHEN MATCHED THEN  
  UPDATE SET Balance = Balance + TransactionValue;  

3、Attempt to insert a new stock item along with the quantity of stock. If the item already exists, instead update the stock count of the existing item. Don't allow entries that have zero stock.

MERGE INTO wines w  
USING wine_stock_changes s  -- 源可以是临时表  
ON s.winename = w.winename  
WHEN NOT MATCHED AND s.stock_delta > 0 THEN  
  INSERT VALUES(s.winename, s.stock_delta)  
WHEN MATCHED AND w.stock + s.stock_delta > 0 THEN  
  UPDATE SET stock = w.stock + s.stock_delta;  
WHEN MATCHED THEN  
  DELETE;  

The wine_stock_changes table might be, for example, a temporary table recently loaded into the database.

4、回归测试中的例子

+-- WITH referenced by MERGE statement  
+CREATE TABLE m AS SELECT i AS k, (i || ' v')::text v FROM generate_series(1, 16, 3) i;  
+ALTER TABLE m ADD UNIQUE (k);  
+WITH RECURSIVE cte_basic AS (SELECT 1 a, 'cte_basic val' b)  
+MERGE INTO m USING (select 0 k, 'merge source SubPlan' v) o ON m.k=o.k  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v);  
+ERROR:  WITH RECURSIVE is not supported for MERGE statement  
+-- Basic:  
+WITH cte_basic AS (SELECT 1 a, 'cte_basic val' b)  
+MERGE INTO m USING (select 0 k, 'merge source SubPlan' v) o ON m.k=o.k  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v);  
+-- Examine  
+SELECT * FROM m where k = 0;  
+ k |          v             
+---+----------------------  
+ 0 | merge source SubPlan  
+(1 row)  
+  
+-- See EXPLAIN output for same query:  
+EXPLAIN (VERBOSE, COSTS OFF)  
+WITH cte_basic AS (SELECT 1 a, 'cte_basic val' b)  
+MERGE INTO m USING (select 0 k, 'merge source SubPlan' v) o ON m.k=o.k  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v);  
+                            QUERY PLAN                               
+-------------------------------------------------------------------  
+ Merge on public.m  
+   CTE cte_basic  
+     ->  Result  
+           Output: 1, 'cte_basic val'::text  
+   ->  Hash Right Join  
+         Output: o.k, o.v, o.*, m_1.ctid  
+         Hash Cond: (m_1.k = o.k)  
+         ->  Seq Scan on public.m m_1  
+               Output: m_1.ctid, m_1.k  
+         ->  Hash  
+               Output: o.k, o.v, o.*  
+               ->  Subquery Scan on o  
+                     Output: o.k, o.v, o.*  
+                     ->  Result  
+                           Output: 0, 'merge source SubPlan'::text  
+   SubPlan 2  
+     ->  Limit  
+           Output: ((cte_basic.b || ' merge update'::text))  
+           ->  CTE Scan on cte_basic  
+                 Output: (cte_basic.b || ' merge update'::text)  
+                 Filter: (cte_basic.a = m.k)  
+(21 rows)  
+  
+-- InitPlan  
+WITH cte_init AS (SELECT 1 a, 'cte_init val' b)  
+MERGE INTO m USING (select 1 k, 'merge source InitPlan' v) o ON m.k=o.k  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v);  
+-- Examine  
+SELECT * FROM m where k = 1;  
+ k |             v               
+---+---------------------------  
+ 1 | cte_init val merge update  
+(1 row)  
+  
+-- See EXPLAIN output for same query:  
+EXPLAIN (VERBOSE, COSTS OFF)  
+WITH cte_init AS (SELECT 1 a, 'cte_init val' b)  
+MERGE INTO m USING (select 1 k, 'merge source InitPlan' v) o ON m.k=o.k  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v);  
+                             QUERY PLAN                               
+--------------------------------------------------------------------  
+ Merge on public.m  
+   CTE cte_init  
+     ->  Result  
+           Output: 1, 'cte_init val'::text  
+   InitPlan 2 (returns $1)  
+     ->  Limit  
+           Output: ((cte_init.b || ' merge update'::text))  
+           ->  CTE Scan on cte_init  
+                 Output: (cte_init.b || ' merge update'::text)  
+                 Filter: (cte_init.a = 1)  
+   ->  Hash Right Join  
+         Output: o.k, o.v, o.*, m_1.ctid  
+         Hash Cond: (m_1.k = o.k)  
+         ->  Seq Scan on public.m m_1  
+               Output: m_1.ctid, m_1.k  
+         ->  Hash  
+               Output: o.k, o.v, o.*  
+               ->  Subquery Scan on o  
+                     Output: o.k, o.v, o.*  
+                     ->  Result  
+                           Output: 1, 'merge source InitPlan'::text  
+(21 rows)  
+  
+-- MERGE source comes from CTE:  
+WITH merge_source_cte AS (SELECT 15 a, 'merge_source_cte val' b)  
+MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte));  
+-- Examine  
+SELECT * FROM m where k = 15;  
+ k  |                              v                                 
+----+--------------------------------------------------------------  
+ 15 | merge_source_cte val(15,"merge_source_cte val") merge insert  
+(1 row)  
+  
+-- See EXPLAIN output for same query:  
+EXPLAIN (VERBOSE, COSTS OFF)  
+WITH merge_source_cte AS (SELECT 15 a, 'merge_source_cte val' b)  
+MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a  
+WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15)  
+WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte));  
+                                                  QUERY PLAN                                                     
+---------------------------------------------------------------------------------------------------------------  
+ Merge on public.m  
+   CTE merge_source_cte  
+     ->  Result  
+           Output: 15, 'merge_source_cte val'::text  
+   InitPlan 2 (returns $1)  
+     ->  CTE Scan on merge_source_cte merge_source_cte_1  
+           Output: ((merge_source_cte_1.b || (merge_source_cte_1.*)::text) || ' merge update'::text)  
+           Filter: (merge_source_cte_1.a = 15)  
+   InitPlan 3 (returns $2)  
+     ->  CTE Scan on merge_source_cte merge_source_cte_2  
+           Output: ((merge_source_cte_2.*)::text || ' merge insert'::text)  
+   ->  Hash Right Join  
+         Output: merge_source_cte.a, merge_source_cte.b, ROW(merge_source_cte.a, merge_source_cte.b), m_1.ctid  
+         Hash Cond: (m_1.k = merge_source_cte.a)  
+         ->  Seq Scan on public.m m_1  
+               Output: m_1.ctid, m_1.k  
+         ->  Hash  
+               Output: merge_source_cte.a, merge_source_cte.b  
+               ->  CTE Scan on merge_source_cte  
+                     Output: merge_source_cte.a, merge_source_cte.b  
+(20 rows)  
+  
+DROP TABLE m;  

5、个人测试例子

目标表触发器

create or replace function tg() returns trigger as $$  
declare  
begin  
  raise notice '%', new;  
  return null;  
end;  
$$ language plpgsql strict;  

目标表

create table t1(id int primary key, info text, crt_time timestamp);  

源表

create table t2(id int primary key, info text, crt_time timestamp);  

写入100条测试数据到源表

postgres=# insert into t2 select generate_series(1,100),random()*100, now();  
INSERT 0 100  

创建目标表触发器

postgres=# create trigger tg after insert on t1 for each row execute procedure tg();  
CREATE TRIGGER  

使用merge into,将源表数据合并到目标表,并触发了INSERT触发器

postgres=#   
merge into t1 using t2   
on t1.id=t2.id   
when not matched then insert (id,info,crt_time) values (t2.id,t2.info,t2.crt_time)   
when matched and t1.info<>t2.info or t1.crt_time<>t2.crt_time then update set info=t2.info , crt_time=t2.crt_time;  
  
NOTICE:  (1,29.9749359954149,"2018-04-07 22:03:31.531152")  
NOTICE:  (2,93.1852474343032,"2018-04-07 22:03:31.531152")  
NOTICE:  (3,25.758066913113,"2018-04-07 22:03:31.531152")  
NOTICE:  (4,69.128438225016,"2018-04-07 22:03:31.531152")  
NOTICE:  (5,34.7714505158365,"2018-04-07 22:03:31.531152")  
NOTICE:  (6,47.4942798726261,"2018-04-07 22:03:31.531152")  
NOTICE:  (7,61.8766254279763,"2018-04-07 22:03:31.531152")  
NOTICE:  (8,97.1885625738651,"2018-04-07 22:03:31.531152")  
NOTICE:  (9,7.41707538254559,"2018-04-07 22:03:31.531152")  
NOTICE:  (10,70.8636813331395,"2018-04-07 22:03:31.531152")  
NOTICE:  (11,33.8312264997512,"2018-04-07 22:03:31.531152")  
NOTICE:  (12,77.4763741064817,"2018-04-07 22:03:31.531152")  
NOTICE:  (13,5.14419632963836,"2018-04-07 22:03:31.531152")  
NOTICE:  (14,86.3092178478837,"2018-04-07 22:03:31.531152")  
NOTICE:  (15,41.1678662057966,"2018-04-07 22:03:31.531152")  
NOTICE:  (16,27.8295359108597,"2018-04-07 22:03:31.531152")  
NOTICE:  (17,77.8380565810949,"2018-04-07 22:03:31.531152")  
NOTICE:  (18,13.997572241351,"2018-04-07 22:03:31.531152")  
NOTICE:  (19,34.8465123679489,"2018-04-07 22:03:31.531152")  
NOTICE:  (20,26.4941859059036,"2018-04-07 22:03:31.531152")  
NOTICE:  (21,88.9189361128956,"2018-04-07 22:03:31.531152")  
NOTICE:  (22,21.6747588012367,"2018-04-07 22:03:31.531152")  
NOTICE:  (23,41.413659369573,"2018-04-07 22:03:31.531152")  
NOTICE:  (24,19.375761738047,"2018-04-07 22:03:31.531152")  
NOTICE:  (25,53.5534802824259,"2018-04-07 22:03:31.531152")  
NOTICE:  (26,82.7209649607539,"2018-04-07 22:03:31.531152")  
NOTICE:  (27,39.306652918458,"2018-04-07 22:03:31.531152")  
NOTICE:  (28,41.2743093911558,"2018-04-07 22:03:31.531152")  
NOTICE:  (29,79.2670299764723,"2018-04-07 22:03:31.531152")  
NOTICE:  (30,40.3565632645041,"2018-04-07 22:03:31.531152")  
NOTICE:  (31,54.4456570409238,"2018-04-07 22:03:31.531152")  
NOTICE:  (32,9.24196597188711,"2018-04-07 22:03:31.531152")  
NOTICE:  (33,33.5418107453734,"2018-04-07 22:03:31.531152")  
NOTICE:  (34,80.203724000603,"2018-04-07 22:03:31.531152")  
NOTICE:  (35,78.3704041969031,"2018-04-07 22:03:31.531152")  
NOTICE:  (36,68.3132612612098,"2018-04-07 22:03:31.531152")  
NOTICE:  (37,27.698003873229,"2018-04-07 22:03:31.531152")  
NOTICE:  (38,40.2470296714455,"2018-04-07 22:03:31.531152")  
NOTICE:  (39,65.5018238350749,"2018-04-07 22:03:31.531152")  
NOTICE:  (40,35.1150792557746,"2018-04-07 22:03:31.531152")  
NOTICE:  (41,11.110711004585,"2018-04-07 22:03:31.531152")  
NOTICE:  (42,99.3330503813922,"2018-04-07 22:03:31.531152")  
NOTICE:  (43,12.5914534088224,"2018-04-07 22:03:31.531152")  
NOTICE:  (44,16.2549073807895,"2018-04-07 22:03:31.531152")  
NOTICE:  (45,85.6422682292759,"2018-04-07 22:03:31.531152")  
NOTICE:  (46,53.759319614619,"2018-04-07 22:03:31.531152")  
NOTICE:  (47,44.0844432916492,"2018-04-07 22:03:31.531152")  
NOTICE:  (48,63.4803248103708,"2018-04-07 22:03:31.531152")  
NOTICE:  (49,67.75689185597,"2018-04-07 22:03:31.531152")  
NOTICE:  (50,78.9309556595981,"2018-04-07 22:03:31.531152")  
NOTICE:  (51,89.9745107628405,"2018-04-07 22:03:31.531152")  
NOTICE:  (52,56.6758279688656,"2018-04-07 22:03:31.531152")  
NOTICE:  (53,0.60571450740099,"2018-04-07 22:03:31.531152")  
NOTICE:  (54,31.3881701324135,"2018-04-07 22:03:31.531152")  
NOTICE:  (55,76.0515897534788,"2018-04-07 22:03:31.531152")  
NOTICE:  (56,54.1591947898269,"2018-04-07 22:03:31.531152")  
NOTICE:  (57,14.1091350931674,"2018-04-07 22:03:31.531152")  
NOTICE:  (58,15.3582426719368,"2018-04-07 22:03:31.531152")  
NOTICE:  (59,95.4335042275488,"2018-04-07 22:03:31.531152")  
NOTICE:  (60,93.3761650696397,"2018-04-07 22:03:31.531152")  
NOTICE:  (61,55.714805983007,"2018-04-07 22:03:31.531152")  
NOTICE:  (62,49.8791612684727,"2018-04-07 22:03:31.531152")  
NOTICE:  (63,2.61813104152679,"2018-04-07 22:03:31.531152")  
NOTICE:  (64,89.2566167283803,"2018-04-07 22:03:31.531152")  
NOTICE:  (65,30.0828852690756,"2018-04-07 22:03:31.531152")  
NOTICE:  (66,80.988535284996,"2018-04-07 22:03:31.531152")  
NOTICE:  (67,57.5698779895902,"2018-04-07 22:03:31.531152")  
NOTICE:  (68,57.7808891423047,"2018-04-07 22:03:31.531152")  
NOTICE:  (69,21.2355649564415,"2018-04-07 22:03:31.531152")  
NOTICE:  (70,23.0717018712312,"2018-04-07 22:03:31.531152")  
NOTICE:  (71,92.8959684446454,"2018-04-07 22:03:31.531152")  
NOTICE:  (72,32.3462759610265,"2018-04-07 22:03:31.531152")  
NOTICE:  (73,22.4047522526234,"2018-04-07 22:03:31.531152")  
NOTICE:  (74,5.48742185346782,"2018-04-07 22:03:31.531152")  
NOTICE:  (75,48.6011833418161,"2018-04-07 22:03:31.531152")  
NOTICE:  (76,8.04702048189938,"2018-04-07 22:03:31.531152")  
NOTICE:  (77,59.2467414680868,"2018-04-07 22:03:31.531152")  
NOTICE:  (78,92.6856266334653,"2018-04-07 22:03:31.531152")  
NOTICE:  (79,71.5273452922702,"2018-04-07 22:03:31.531152")  
NOTICE:  (80,27.003633370623,"2018-04-07 22:03:31.531152")  
NOTICE:  (81,71.6165823396295,"2018-04-07 22:03:31.531152")  
NOTICE:  (82,61.5018560551107,"2018-04-07 22:03:31.531152")  
NOTICE:  (83,83.6794613394886,"2018-04-07 22:03:31.531152")  
NOTICE:  (84,72.2222968470305,"2018-04-07 22:03:31.531152")  
NOTICE:  (85,92.8900261875242,"2018-04-07 22:03:31.531152")  
NOTICE:  (86,59.7310510929674,"2018-04-07 22:03:31.531152")  
NOTICE:  (87,26.3814916368574,"2018-04-07 22:03:31.531152")  
NOTICE:  (88,6.99916132725775,"2018-04-07 22:03:31.531152")  
NOTICE:  (89,75.0892938114703,"2018-04-07 22:03:31.531152")  
NOTICE:  (90,21.8149958644062,"2018-04-07 22:03:31.531152")  
NOTICE:  (91,0.375326396897435,"2018-04-07 22:03:31.531152")  
NOTICE:  (92,30.8040997944772,"2018-04-07 22:03:31.531152")  
NOTICE:  (93,71.694157179445,"2018-04-07 22:03:31.531152")  
NOTICE:  (94,2.99345748499036,"2018-04-07 22:03:31.531152")  
NOTICE:  (95,20.0607165228575,"2018-04-07 22:03:31.531152")  
NOTICE:  (96,1.77704244852066,"2018-04-07 22:03:31.531152")  
NOTICE:  (97,83.9819927699864,"2018-04-07 22:03:31.531152")  
NOTICE:  (98,77.6305945124477,"2018-04-07 22:03:31.531152")  
NOTICE:  (99,59.5579316373914,"2018-04-07 22:03:31.531152")  
NOTICE:  (100,5.21755772642791,"2018-04-07 22:03:31.531152")  
MERGE 100  

再次执行,由于设置了条件t1.info<>t2.info or t1.crt_time<>t2.crt_time才更新,所以MERGE 0条.

postgres=# merge into t1 using t2   
on t1.id=t2.id   
when not matched then insert (id,info,crt_time) values (t2.id,t2.info,t2.crt_time)   
when matched and t1.info<>t2.info or t1.crt_time<>t2.crt_time then update set info=t2.info , crt_time=t2.crt_time;  
MERGE 0  

把条件t1.info<>t2.info or t1.crt_time<>t2.crt_time去掉,MERGE了100条(update)

postgres=#   
merge into t1 using t2   
on t1.id=t2.id   
when not matched then insert (id,info,crt_time) values (t2.id,t2.info,t2.crt_time)   
when matched then update set info=t2.info , crt_time=t2.crt_time;  
MERGE 100  

目前merge into语法与rule不能同时使用,也就是说如果目标表上有insert\update\delete的RULE的话,不能使用merge into来合并数据到目标表。

postgres=# create rule r1 as on insert to t1 do instead nothing;
CREATE RULE

postgres=# insert into t1 values (0);
INSERT 0 0

postgres=# truncate t1;
TRUNCATE TABLE

postgres=# \set VERBOSITY verbose

postgres=# merge into t1 using t2 
on t1.id=t2.id 
when not matched then insert (id,info,crt_time) values (t2.id,t2.info,t2.crt_time) 
when matched and t1.info<>t2.info or t1.crt_time<>t2.crt_time then update set info=t2.info , crt_time=t2.crt_time;

ERROR:  0A000: MERGE is not supported for relations with rules
LOCATION:  transformMergeStmt, parse_merge.c:424

参考

https://www.postgresql.org/docs/devel/static/sql-merge.html

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=e6597dc3533946b98acba7871bd4ca1f7a3d4c1d

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=354f13855e6381d288dfaa52bcd4f2cb0fd4a5eb

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=7cf8a5c302735d193dcf901b87e03e324903c632

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=aa5877bb26347c58a34aee4e460eb1e1123bb096

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=d204ef63776b8a00ca220adec23979091564e465

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=83454e3c2b28141c0db01c7d2027e01040df5249

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=aa3faa3c7a7a49b3318059ccaf79bc1886a64707

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=4923550c20ae6d122ae0867480a7de8b040f7d80

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
SQL Oracle 关系型数据库
实时计算 Flink版操作报错之往GREENPLUM 6 写数据,用postgresql-42.2.9.jar 报 ON CONFLICT (uuid) DO UPDATE SET 语法有问题。怎么解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
Oracle 关系型数据库 数据库
Oracle中merge Into的用法
Oracle中merge Into的用法
|
关系型数据库 分布式数据库 数据库
PolarDB PostgreSQL版:Oracle兼容的高性能数据库
PolarDB PostgreSQL版是一款高性能的数据库,具有与Oracle兼容的特性。它采用了分布式架构,可以轻松处理大量的数据,同时还支持多种数据类型和函数,具有高可用性和可扩展性。它还提供了丰富的管理工具和性能优化功能,为企业提供了可靠的数据存储和处理解决方案。PolarDB PostgreSQL版在数据库领域具有很高的竞争力,可以满足各种企业的需求。
|
9月前
|
SQL
SQL如何在CTE中使用Order By的功能
SQL Server如何在CTE中使用Order By的功能
|
10月前
|
SQL 关系型数据库 PostgreSQL
CTE vs 子查询:深入拆解PostgreSQL复杂SQL的隐藏性能差异
本文深入探讨了PostgreSQL中CTE(公共表表达式)与子查询的选择对SQL性能的影响。通过分析两者底层机制,揭示CTE的物化特性及子查询的优化融合优势,并结合多场景案例对比执行效率。最终给出决策指南,帮助开发者根据数据量、引用次数和复杂度选择最优方案,同时提供高级优化技巧和版本演进建议,助力SQL性能调优。
1118 1
|
SQL 关系型数据库 MySQL
SQL Server、MySQL、PostgreSQL:主流数据库SQL语法异同比较——深入探讨数据类型、分页查询、表创建与数据插入、函数和索引等关键语法差异,为跨数据库开发提供实用指导
【8月更文挑战第31天】SQL Server、MySQL和PostgreSQL是当今最流行的关系型数据库管理系统,均使用SQL作为查询语言,但在语法和功能实现上存在差异。本文将比较它们在数据类型、分页查询、创建和插入数据以及函数和索引等方面的异同,帮助开发者更好地理解和使用这些数据库。尽管它们共用SQL语言,但每个系统都有独特的语法规则,了解这些差异有助于提升开发效率和项目成功率。
2063 0
|
关系型数据库 数据库 PostgreSQL
PostgreSQL数据库的字符串拼接语法使用说明
【6月更文挑战第11天】PostgreSQL数据库的字符串拼接语法使用说明
2013 1
|
关系型数据库 PostgreSQL
postgresql字符串拼接语法
【5月更文挑战第6天】postgresql字符串拼接语法
1055 0
|
SQL 关系型数据库 分布式数据库
阿里云PolarDB是一款兼容MySQL、PostgreSQL和SQL Server等多种数据库协议的产品
阿里云PolarDB是一款兼容MySQL、PostgreSQL和SQL Server等多种数据库协议的产品
1161 6
|
SQL 关系型数据库 MySQL
MySQL【实践 02】MySQL迁移到PostgreSQL数据库的语法调整说明及脚本分享(通过bat命令修改mapper文件内的SQL语法)
MySQL【实践 02】MySQL迁移到PostgreSQL数据库的语法调整说明及脚本分享(通过bat命令修改mapper文件内的SQL语法)
670 0

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版
  • 推荐镜像

    更多