Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Bosco Rama
Carlos Mennens wrote: > On Tue, May 17, 2011 at 2:21 PM, Raymond O'Donnell 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; >>

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Susan Cassidy
> Doesn't the SERIAL shortcut automatically do this on the fly? How > would I set this? > > ALTER TABLE table_name ALTER COLUMN id SET DEFAULT nextval('foo_seq_id'); If you have existing data, say with values 1, 2, 3, etc. and you set the column to start using a sequence nextval as default, unle

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 2:32 PM, Susan Cassidy wrote: > Don't forget to use setval to set the current value of the sequence to the > highest number used in the data already, so that the next insertion uses a > new, unused value. Doesn't the SERIAL shortcut automatically do this on the fly? How

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Susan Cassidy
Don't forget to use setval to set the current value of the sequence to the highest number used in the data already, so that the next insertion uses a new, unused value. Susan Cassidy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: ht

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Adrian Klaver
On 05/17/2011 11:29 AM, Carlos Mennens wrote: On Tue, May 17, 2011 at 2:21 PM, Raymond O'Donnell 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 user

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 2:21 PM, Raymond O'Donnell 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

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Raymond O'Donnell
On 17/05/2011 19:07, Carlos Mennens wrote: On Tue, May 17, 2011 at 12:57 PM, Carlos Mennens wrote: On Tue, May 17, 2011 at 12:38 PM, Raymond O'Donnell wrote: Yes, that's exactly right - SERIAL does it all for you. The mistake some people make, on the other hand, is thinking that SERIAL is a

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 12:57 PM, Carlos Mennens wrote: > On Tue, May 17, 2011 at 12:38 PM, Raymond O'Donnell wrote: >> Yes, that's exactly right - SERIAL does it all for you. The mistake some >> people make, on the other hand, is thinking that SERIAL is a type in its own >> right - it's not, it

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 12:38 PM, Raymond O'Donnell wrote: > Yes, that's exactly right - SERIAL does it all for you. The mistake some > people make, on the other hand, is thinking that SERIAL is a type in its own > right - it's not, it just does all those steps automatically. This information you

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Raymond O'Donnell
On 17/05/2011 17:35, Carlos Mennens wrote: On Tue, May 17, 2011 at 12:12 PM, Raymond O'Donnell wrote: Well, the SERIAL pseudo-type creates the sequence, associates it with the column, and sets a DEFAULT on the column which executes the nextval() function on the sequence - all in one fell swoop.

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 12:12 PM, Raymond O'Donnell wrote: > Well, the SERIAL pseudo-type creates the sequence, associates it with the > column, and sets a DEFAULT on the column which executes the nextval() > function on the sequence - all in one fell swoop. Read all about it here: > > http://www.

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Raymond O'Donnell
On 17/05/2011 16:26, Carlos Mennens wrote: On Tue, May 17, 2011 at 11:22 AM, Jaime Casanova wrote: in postgres is as easy as CREATE TABLE test( id SERIAL PRIMARY KEY); hey! it's even less keystrokes! I don't understand how this command above is associated with being able to auto increment

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Tue, May 17, 2011 at 11:22 AM, Jaime Casanova wrote: > in postgres is as easy as > > CREATE TABLE test( >  id SERIAL PRIMARY KEY); > > hey! it's even less keystrokes! I don't understand how this command above is associated with being able to auto increment the 'id' column. Sorry I'm still lear

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Jaime Casanova
On Tue, May 17, 2011 at 10:14 AM, Carlos Mennens wrote: > > Yes that worked perfect! I'm just curious if I have 20 tables and then > want all the 'id' columns to be auto incrementing , that means I have > to have 20 listed sequences for all 20 unique tables? yes > Seems very > cluttered and mess

Re: [GENERAL] Remove Modifiers on Table

2011-05-17 Thread Carlos Mennens
On Mon, May 16, 2011 at 4:58 PM, Bosco Rama wrote: > If you are truly intent on removing the sequence you'll need to do the > following: > >   alter sequence users_seq_id owned by NONE >   alter table users alter column id drop default >   drop sequence users_seq_id Yes that worked perfect! I'm j

Re: [GENERAL] Remove Modifiers on Table

2011-05-16 Thread Bosco Rama
Carlos Mennens wrote: > I created a modifier for auto incrementing my primary key as follows: > > records=# \d users > Table "public.users" > Column | Type | Modifiers > +---+-

[GENERAL] Remove Modifiers on Table

2011-05-16 Thread Carlos Mennens
I created a modifier for auto incrementing my primary key as follows: records=# \d users Table "public.users" Column | Type | Modifiers +---+ id