Subject Unique constraint not enforced?
Author Laurent Duperval
Good day,

I am trying to create a unique constraint in one of my tables but it is
not working as I expected. I tried both of these approaches:

CREATE TABLE Vehicle
(
Id char(10),
Name varchar(32) NOT NULL unique,
CONSTRAINT PK_Vehicle PRIMARY KEY (Id)
);

and

CREATE TABLE Vehicle
(
Id char(10),
Name varchar(32) NOT NULL ,
CONSTRAINT PK_Vehicle PRIMARY KEY (Id),
CONSTRAINT UNQ_VEHICLE_NAME UNIQUE (NAME)
);

In both cases, I was able to do the following wthout error:

insert into Vehicle values ('1', 'Foo');
insert into Vehicle values ('2', 'Foo');

I expected the second statement to cause an error. What I'm after is a
way to insert entries in a table with unique names. What is the proper
way to do this?

I am using Firebird 1.5 on Windows 2000. The exact version is
WI-V1.5.1.4481 Firebird 1.5.

Thanks,

L