Re: Remove Modifiers on Table
От | Adrian Klaver |
---|---|
Тема | Re: Remove Modifiers on Table |
Дата | |
Msg-id | 4DD2BF7D.8080005@gmail.com обсуждение исходный текст |
Ответ на | Re: Remove Modifiers on Table (Carlos Mennens <carlos.mennens@gmail.com>) |
Ответы |
Re: Remove Modifiers on Table
|
Список | pgsql-general |
On 05/17/2011 11:29 AM, Carlos Mennens wrote: > On Tue, May 17, 2011 at 2:21 PM, Raymond O'Donnell<rod@iol.ie> wrote: >> That's because of what I just mentioned above. :-) It's not a type: it's >> just a shortcut. What you need to do instead is something like this: >> >> -- Create the sequence. >> create sequence users_id_seq; >> >> -- Tell the column to pull default values from the sequence. >> alter table users alter column id set default nextval('users_id_seq'); >> >> -- Establish a dependency between the column and the sequence. >> alter sequence users_id_seq owned by users.id; > > Yup - that explains that the shortcut doesn't work for existing tables > but only during CREATE TABLE. Otherwise I will need to manually CREATE > SEQUENCE...blah blah blah. It will work for an existing table if you are adding a column with 'type' SERIAL. You just cannot change an existing column to 'type' SERIAL. > > Thank you! > -- Adrian Klaver adrian.klaver@gmail.com
В списке pgsql-general по дате отправления: