数据仓库服务 GAUSSDB(DWS)-UPSERT:示例

时间:2024-01-25 15:18:14

示例

创建表reason_upsert并向表中插入数据:
1
2
3
4
5
6
7
CREATE TABLE reason_upsert
(
  a    int primary key,
  b    int,
  c    int
)WITH(ORIENTATION=COLUMN, ENABLE_HSTORE=ON);
INSERT INTO reason_upsert VALUES (1, 2, 3);
忽略冲突的数据:
1
INSERT INTO reason_upsert  VALUES (1, 4, 5),(2, 6, 7) ON CONFLICT(a) DO NOTHING;
更新冲突的数据:
1
INSERT INTO reason_upsert  VALUES (1, 4, 5),(3, 8, 9) ON CONFLICT(a) DO UPDATE SET b = EXCLUDED.b, c = EXCLUDED.c;
support.huaweicloud.com/HybridDevg-dws/dws_15_00009.html