Skip to content

Commit 6f6cd16

Browse files
committed
Remove limitation
Tracks duckdb/duckdb#18480
1 parent 598f5ea commit 6f6cd16

1 file changed

Lines changed: 0 additions & 24 deletions

File tree

docs/lts/sql/statements/insert.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -265,30 +265,6 @@ INSERT INTO tbl BY NAME
265265
ON CONFLICT DO UPDATE SET j = EXCLUDED.j;
266266
```
267267

268-
#### Limitations
269-
270-
When the `ON CONFLICT ... DO UPDATE` clause is used and a conflict occurs, DuckDB internally assigns `NULL` values to the row's columns that are unaffected by the conflict, then re-assigns their values. If the affected columns use a `NOT NULL` constraint, this will trigger a `NOT NULL constraint failed` error. For example:
271-
272-
```sql
273-
CREATE TABLE t1 (id INTEGER PRIMARY KEY, val1 DOUBLE, val2 DOUBLE NOT NULL);
274-
CREATE TABLE t2 (id INTEGER PRIMARY KEY, val1 DOUBLE);
275-
INSERT INTO t1
276-
VALUES (1, 2, 3);
277-
INSERT INTO t2
278-
VALUES (1, 5);
279-
280-
INSERT INTO t1 BY NAME (SELECT id, val1 FROM t2)
281-
ON CONFLICT DO UPDATE
282-
SET val1 = EXCLUDED.val1;
283-
```
284-
285-
This fails with the following error:
286-
287-
```console
288-
Constraint Error:
289-
NOT NULL constraint failed: t1.val2
290-
```
291-
292268
#### Composite Primary Key
293269

294270
When multiple columns need to be part of the uniqueness constraint, use a single `PRIMARY KEY` clause including all relevant columns:

0 commit comments

Comments
 (0)