Re: Creating a new column with SERIAL as data type

Поиск
Список
Период
Сортировка
От Kumar S
Тема Re: Creating a new column with SERIAL as data type
Дата
Msg-id 20040920041859.60891.qmail@web61207.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: Creating a new column with SERIAL as data type  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Thank you very much Mr. Lane.
It worked.
Would you mind explaining the code that you sent.
I would appreciate and curious to learn in fact the
meaning of the pg/pl sql statements.
thank you.
Kumar.


--- Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Kumar S <ps_postgres@yahoo.com> writes:
> > friends=> alter table friend  add column fr_id
> serial;
> > NOTICE:  ALTER TABLE will create implicit sequence
> "friend_fr_id_seq" for "serial" column
> "friend.fr_id"
> > ERROR:  adding columns with defaults is not
> implemented
> > HINT:  Add the column, then use ALTER TABLE SET
> DEFAULT.
>
> > Can any one suggest what is wrong here.
>
> Just what it says: adding columns with defaults is
> not implemented.
> (It is implemented in 8.0, but that won't help you
> today.)  You can
> do it by hand:
>
> create sequence friend_fr_id_seq;
> alter table friend add column fr_id int;
> update friend set fr_id =
> nextval('friend_fr_id_seq');
> alter table friend alter column fr_id set default
> nextval('friend_fr_id_seq');
>
> This isn't an exact substitute since the sequence
> will appear as
> a standalone object and not be hidden behind the
> "serial" column,
> but it's functionally equivalent.
>
>             regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map
> settings
>




__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Creating a new column with SERIAL as data type
Следующее
От: Martin Atukunda
Дата:
Сообщение: ECPG threads