help with serial type
| От | Jason |
|---|---|
| Тема | help with serial type |
| Дата | |
| Msg-id | 3AE6AF09.501FF08E@mediaone.net обсуждение исходный текст |
| Ответы |
Re: help with serial type
Re: help with serial type |
| Список | 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 по дате отправления: