2004-11-28 22:28:36 +01:00
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
pk1 INT NOT NULL PRIMARY KEY,
|
|
|
|
b INT NOT NULL,
|
2005-04-19 11:21:26 +02:00
|
|
|
c INT NOT NULL UNIQUE
|
2004-11-28 22:28:36 +01:00
|
|
|
) ENGINE=ndbcluster;
|
2005-04-19 11:21:26 +02:00
|
|
|
INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2);
|
2004-11-28 22:28:36 +01:00
|
|
|
UPDATE t1 set b = c;
|
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
2005-04-19 11:21:26 +02:00
|
|
|
0 0 0
|
|
|
|
1 1 1
|
|
|
|
2 2 2
|
|
|
|
UPDATE t1 set pk1 = 4 where pk1 = 1;
|
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
|
|
|
0 0 0
|
|
|
|
2 2 2
|
|
|
|
4 1 1
|
2006-11-29 11:53:43 +01:00
|
|
|
UPDATE t1 set pk1 = 4 where pk1 = 2;
|
|
|
|
ERROR 23000: Duplicate entry '4' for key 1
|
|
|
|
UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2;
|
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
|
|
|
0 0 0
|
|
|
|
2 2 2
|
|
|
|
4 1 1
|
2005-04-19 11:21:26 +02:00
|
|
|
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
|
2007-12-06 17:15:21 +01:00
|
|
|
ERROR 23000: Duplicate entry '2' for key 2
|
2006-11-30 15:02:33 +01:00
|
|
|
UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4;
|
2005-04-19 11:21:26 +02:00
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
|
|
|
0 0 0
|
|
|
|
2 2 2
|
|
|
|
4 1 1
|
|
|
|
UPDATE t1 set pk1 = pk1 + 10;
|
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
|
|
|
10 0 0
|
|
|
|
12 2 2
|
|
|
|
14 1 1
|
2007-10-02 13:36:13 +02:00
|
|
|
create unique index ib on t1(b);
|
|
|
|
update t1 set c = 4 where pk1 = 12;
|
|
|
|
update ignore t1 set b = 55 where pk1 = 14;
|
|
|
|
select * from t1 order by pk1;
|
|
|
|
pk1 b c
|
|
|
|
10 0 0
|
|
|
|
12 2 4
|
|
|
|
14 55 1
|
2005-04-19 11:21:26 +02:00
|
|
|
DROP TABLE IF EXISTS t1;
|