Re: Migration problem - serial fields
От | Brent Verner |
---|---|
Тема | Re: Migration problem - serial fields |
Дата | |
Msg-id | 20020307160101.GA80416@rcfile.org обсуждение исходный текст |
Ответ на | Migration problem - serial fields ("Rick Anderson" <rick@planetdigital.com>) |
Список | pgsql-general |
[2002-03-04 14:07] Rick Anderson said: | The snag I'm encountering is with Identity fields in SQL7. I discovered the | equivalent in PG -- sequences/serial field. I would like to use serial if | possible, but here's the problem: getting the existing records over while | *keeping the existing values* for the Identity/sequence ID fields. They | actually transfer over fine, but the next insert into the PG table | generates a duplicate ID error. It seems obvious that my transfer did not | update the sequence used by the serial field. However, I'm just not sure of | the best course of action. You need to use something like db=> select setval('$A',(select max($B) from $C)+1); where $A = serial-sequence name $B = serial column name $C = table name hth. brent -- "Develop your talent, man, and leave the world something. Records are really gifts from people. To think that an artist would love you enough to share his music with anyone is a beautiful thing." -- Duane Allman
В списке pgsql-general по дате отправления: