mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
44 lines
928 B
Text
44 lines
928 B
Text
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
|
INSERT t1 VALUES (1,2,10), (3,4,20);
|
|
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE SET c=c+100;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10
|
|
3 4 20
|
|
5 6 30
|
|
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE SET c=c+100;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10
|
|
3 4 20
|
|
5 6 130
|
|
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE SET c=c+1000;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10
|
|
3 4 1020
|
|
5 6 130
|
|
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE SET c=c+10000;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10010
|
|
3 4 1020
|
|
5 6 130
|
|
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE SET c=c+100000, b=4;
|
|
Duplicate entry '4' for key 2
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10010
|
|
3 4 1020
|
|
5 6 130
|
|
TRUNCATE TABLE t1;
|
|
INSERT t1 VALUES (1,2,10), (3,4,20);
|
|
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE SET c=c+100;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 10
|
|
3 4 120
|
|
5 6 30
|
|
8 9 60
|
|
DROP TABLE t1;
|