help with serial type - Mailing list pgsql-general

From Jason
Subject help with serial type
Date
Msg-id 3AE6AF09.501FF08E@mediaone.net
Whole thread Raw
Responses Re: help with serial type
Re: help with serial type
List pgsql-general
Hi , I'm a postgreSQL newbie.  I have a table called "atable" that has
the columns:
title varchar(20)
name  varchar(20)
id serial
if I do:
INSERT INTO TABLE atable VALUES('SQL1','Jason')
the 'id' gets updated with a new number automatically.  I then later
added a new column called 'date'.  Now if I do an insert with:
INSERT INTO TABLE atable VALUES('SQL2','Toy','',date('now'))
the id will update the first time to '0', but using this command again:
 INSERT INTO TABLE atable VALUES('SQL3','Toy','',date('now'))
it won't let me update because there are duplicate 'id's.
I also tried
INSERT INTO TABLE a(title, name, date) VALUES('SQL3','Toy',date('now'))
but it won't automatically update 'id' also.  How can I make the insert
command automatically update the 'id' to the next highest number?  or
how can I rearrange the columns so that 'id' is the last column and
'date' comes before 'id' so that way 'id' will automatically update.
thanks in advance.
Jason Toy


pgsql-general by date:

Previous
From: "Alejandro Cicero"
Date:
Subject: Consulta
Next
From: "Gregory Wood"
Date:
Subject: Re: newbie ?'s