help with serial type

From: Jason <gee308(at)mediaone(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: help with serial type
Date: 2001-04-25 11:03:37
Message-ID: 3AE6AF09.501FF08E@mediaone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-04-25 11:08:07 Re: Question on Bizarre Sorting (ORDER BY in 7.1) (fwd)
Previous Message Mike Mascari 2001-04-25 10:36:14 RE: I can not create Index on a feild by type 'timestmp'!