Auto-Increment in Postgres

Поиск
Список
Период
Сортировка
От Adarsh Sharma
Тема Auto-Increment in Postgres
Дата
Msg-id 4D5519E2.6090500@orkash.com
обсуждение исходный текст
Ответы Re: Auto-Increment in Postgres  (Thom Brown <thom@linux.com>)
Re: Auto-Increment in Postgres  (Fredric Fredricson <Fredric.Fredricson@bonetmail.com>)
Re: Auto-Increment in Postgres  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
Dear all,


I have an Integer column in Postgres database table. Let's say the column has below values :


1
2
3
4
5
6
7
8
9
10


Now if i deleted some rows where id= 3 ,5 and 8  or it have these type of data then

The data look like as :

1
2
4
6
7
9
10

I want to have it id's as
1
2
3
4
5
6
7
and next data is inserted right at 8 .

I follow these steps

alter table meta_test drop column metadataid;

alter table meta_test add metadataid serial;


But this adds the column at the end but i want to it as primary key.

Please help how to achieve it.


Thanks & best Regards
Adarsh Sharma

В списке pgsql-general по дате отправления:

Предыдущее
От: Andre Lopes
Дата:
Сообщение: Re: Schema version control
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Auto-Increment in Postgres