By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test (
id int primary key,
A int not null default 0,
B int default 0,
C int not null,
D int
);
insert into test (ID, A, B, C, D) values
(1, 10, 100, 1000, 10000),
(2, 20, null, 2000, 20000);
select * from test;
id | A | B | C | D |
---|---|---|---|---|
1 | 10 | 100 | 1000 | 10000 |
2 | 20 | null | 2000 | 20000 |
-- replacing id=2, but without column C
replace test (ID, A, B, D) values (2, 20, 200, 20000);
Field 'C' doesn't have a default value
-- replacing id=2, C included, but without the primary key
replace test (A, B, C, D) values (20, 200, 2000, 20000);
Field 'id' doesn't have a default value
-- replacing id=2, C included, PK included
replace test (ID, A, B, C, D) values (2, 20, 200, 2000, 20000);
select * from test;
id | A | B | C | D |
---|---|---|---|---|
1 | 10 | 100 | 1000 | 10000 |
2 | 20 | 200 | 2000 | 20000 |