1
drop table if exists t1;
3
id int NOT NULL auto_increment,
4
ggid varchar(32) DEFAULT '' NOT NULL,
5
email varchar(64) DEFAULT '' NOT NULL,
6
passwd varchar(32) DEFAULT '' NOT NULL,
10
insert into t1 (ggid,passwd) values ('test1','xxx');
11
insert into t1 (ggid,passwd) values ('test2','yyy');
12
insert into t1 (ggid,passwd) values ('test2','this will fail');
13
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
14
insert into t1 (ggid,id) values ('this will fail',1);
15
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
16
select * from t1 where ggid='test1';
19
select * from t1 where passwd='xxx';
22
select * from t1 where id=2;
25
replace into t1 (ggid,id) values ('this will work',1);
26
replace into t1 (ggid,passwd) values ('test2','this will work');
27
update t1 set id=100,ggid='test2' where id=1;
28
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
32
3 test2 this will work
33
select * from t1 where id=1;
36
select * from t1 where id=999;