Reputation: 2398
$ CREATE TABLE `test` ( `data` char(64), UNIQUE KEY `key` (`data`));
$ INSERT IGNORE INTO test (data) VALUES ('a');
$ INSERT IGNORE INTO test (data) VALUES ('A');
$ SELECT * FROM test;
+------+
| data |
+------+
| a |
+------+
How can I get the second INSERT IGNORE
to add a new entry into the table? Is it possible without redefining the table?
Upvotes: 1
Views: 322
Reputation: 521209
MySQL is refusing to insert the duplicate row as it should. If you want the data
column to be case insensitive you will have to alter the table:
ALTER TABLE `test` CHANGE `data` `data` CHAR( 64 )
CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL
Upvotes: 1
Reputation: 16948
No, it's not possible without DDL. You'd need to change the column collation:
alter table test modify data char(64) collate utf8_bin;
Upvotes: 0