teknet@poczta.onet.pl wrote:
> i found the problem:
>
>
>
> sys=> insert into test2 values(1,'myname');
> INSERT 18765 1
> sys=> insert into test2 (name) values('myname2');
> ERROR: duplicate key violates unique constraint "test2_pkey"
> sys=>
>
> Why is it so ?
>
Because you explicitly put in 1:
values(1,'myname')
and the second insert
values('myname2')
which is short for
values(default, 'myname2')
gets the value for the ID column from the default (which is
nextval('test2_id_seq')) and that's 1 too - there you go, unique constraint
violation.
Remember, this is _not_ mysql, where autoincrement columns are implemented(or so
I hear) by select max(column_in_question) + 1.
>
>
> Thanx
>
> Michal
>
Take care and do read/search the manual, it's quite good !
Regards,
--
Radu-Adrian Popescu
CSA, DBA, Developer
Aldrapay MD
Aldratech Ltd.
+40213212243