Mr. E
Mr. E

Reputation: 2120

MySQL case sensitive insert

I have created a database with case sensitive character set:

Create database Grupo88 character set utf8 collate utf8_bin;

CREATE TABLE Grupo88.Usuarios(
    nombreUsuario varchar(30) primary key,
    clave varchar(120) not null);

INSERT INTO usuarios(nombreUsuario,clave)
       VALUES('guy','pass');
INSERT INTO usuario(nombreUsuario, clave)
       VALUES('Guy', 'password');

The first insert goes well, but the second one says that the value "Guy" already exists. Setting my database to be case sensitive is not enough? How can I do to allow case sensitive inserts?

EDIT: Apparently the problem was in the stored procedure that was inserting into the table 'usuarios'. Scripts posted here work perfectly

Upvotes: 1

Views: 4396

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269753

Try using the binary keyword when you create the table:

CREATE TABLE Grupo88.Usuarios (
    nombreUsuario varchar(30) binary primary key,
    clave varchar(120) not null
);

Here is a SQL Fiddle.

Upvotes: 1

Pamingkas Sevada
Pamingkas Sevada

Reputation: 432

use BINARY in creating the table

mysql>     CREATE TABLE Grupo88.Usuarios
    ->     (
    ->         nombreUsuario varchar(30) BINARY,
    ->         clave varchar(120) not null);
    ->     );

Upvotes: 0

Related Questions