> create table foo ( serial bar primary key, ...
>
That does NOT work on my PostgreSQL 7.4.3. What DOES work is:
(assuming you have table foo)
ALTER TABLE foo ADD COLUMN id int; // create an 'id' field, integer
CREATE SEQUENCE foo_id_seq; // create an auto-incrementing seq.
ALTER TABLE foo ALTER COLUMN id SET DEFAULT nextval('foo_id_seq');
// set the default value of 'id' to be the next value in the sequence
UPDATE foo SET id = nextval('foo_id_seq'); // update existing 'id' column
Am I missing some simpler way ? I remember googling about this for quite some
time and that is the solution I found.
Regards,
Eli
--
Eli Kara
Beyond Security Ltd.
http://www.beyondsecurity.com/
http://www.securiteam.com/
The First Integrated Network and Web Application Vulnerability Scanner:
http://www.beyondsecurity.com/webscan-wp.pdf
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]