| От | Adrian Klaver |
|---|---|
| Тема | Re: alter integer field to serial integer primary key |
| Дата | |
| Msg-id | 200609301349.08403.aklaver@comcast.net обсуждение исходный текст |
| Ответ на | alter integer field to serial integer primary key (rloefgren@forethought.net) |
| Список | pgsql-general |
On Friday 29 September 2006 09:51 am, rloefgren@forethought.net wrote: > I have an integer field of unique, consecutive numbers. Can I change > this to be a serial, primary key field using an ALTER TABLE ALTER > COLUMN command? I haven't been able to stumble over it. > > thanks, > > r > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org I think the easiest way would be to use CREATE SEQUENCE to create a sequence with a start value above that of max(integer field) and then use ALTER TABLE to set the nextval(sequence) as the DEFAULT value. -- Adrian Klaver aklaver@comcast.net
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера