Am Donnerstag, 13. September 2007 schrieb Moritz Lenz: > timtowtdi=> insert into users (username) values ('bar'); > ERROR: duplicate key violates unique constraint "users_pkey" > timtowtdi=> insert into users (username) values ('bar'); > INSERT 0 1 > > an insert into a column (here unsername) that has a 'UNIQUE' constaint on > it fails when tried for the first time (although there is no such value in > the table),
The constraint that is being violated here is the primary key, not the unique constraint on the column username. > CREATE TABLE users ( > id SERIAL PRIMARY KEY NOT NULL, > username VARCHAR(20) UNIQUE, > > password VARCHAR(255), > karma INTEGER DEFAULT 0, > acknowledged SMALLINT DEFAULT 0, > locked SMALLINT DEFAULT 0, > time_stamp TIMESTAMP DEFAULT NOW() > ); > INSERT INTO users (id, username, password, acknowledged, locked) > VALUES (1, 'admin', '', 1, 0); Your problem is that you have manually inserted a value into a column managed by a sequence. Don't do that. Or reset the sequence manually. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]