数据仓库服务 GaussDB(DWS)-UPSERT:示例
时间:2025-02-12 15:01:49
示例
创建表reason_upsert并向表中插入数据:
1234567 |
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/HyDevg-dws/dws_15_00009.html
推荐文章