| 1 |
drop table if exists t1; |
| 2 |
CREATE TABLE t1 ( |
| 3 |
id int(11) NOT NULL auto_increment, |
| 4 |
ggid varchar(32) binary DEFAULT '' NOT NULL, |
| 5 |
email varchar(64) DEFAULT '' NOT NULL, |
| 6 |
passwd varchar(32) binary DEFAULT '' NOT NULL, |
| 7 |
PRIMARY KEY (id), |
| 8 |
UNIQUE ggid (ggid) |
| 9 |
) ENGINE=innodb; |
| 10 |
Warnings: |
| 11 |
Warning 1681 Integer display width is deprecated and will be removed in a future release. |
| 12 |
Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead |
| 13 |
Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead |
| 14 |
insert into t1 (ggid,passwd) values ('test1','xxx'); |
| 15 |
insert into t1 (ggid,passwd) values ('test2','yyy'); |
| 16 |
insert into t1 (ggid,passwd) values ('test2','this will fail'); |
| 17 |
ERROR 23000: Duplicate entry 'test2' for key 't1.ggid' |
| 18 |
insert into t1 (ggid,id) values ('this will fail',1); |
| 19 |
ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' |
| 20 |
select * from t1 where ggid='test1'; |
| 21 |
id ggid email passwd |
| 22 |
1 test1 xxx |
| 23 |
select * from t1 where passwd='xxx'; |
| 24 |
id ggid email passwd |
| 25 |
1 test1 xxx |
| 26 |
select * from t1 where id=2; |
| 27 |
id ggid email passwd |
| 28 |
2 test2 yyy |
| 29 |
replace into t1 (ggid,id) values ('this will work',1); |
| 30 |
replace into t1 (ggid,passwd) values ('test2','this will work'); |
| 31 |
update t1 set id=100,ggid='test2' where id=1; |
| 32 |
ERROR 23000: Duplicate entry 'test2' for key 't1.ggid' |
| 33 |
select * from t1; |
| 34 |
id ggid email passwd |
| 35 |
1 this will work |
| 36 |
3 test2 this will work |
| 37 |
select * from t1 where id=1; |
| 38 |
id ggid email passwd |
| 39 |
1 this will work |
| 40 |
select * from t1 where id=999; |
| 41 |
id ggid email passwd |
| 42 |
drop table t1; |
| 43 |
End of tests |