pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedadding fields
4+ messages / 3 participants
[nested] [flat]
* adding fields
@ 2002-01-18 14:55 Jodi Kanter <jkanter@virginia.edu>
0 siblings, 2 replies; 4+ messages in thread
From: Jodi Kanter @ 2002-01-18 14:55 UTC (permalink / raw)
To: pgsql-admin
I need to add a field to an existing table that contains a good amount of data. Do I need to drop table, recreate, and then reload data to do this? I cannot seem to find any documentation to say otherwise.
Thanks
Jodi
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: adding fields
@ 2002-01-18 15:14 Florian Helmberger <f.helmberger@uptime.at>
parent: Jodi Kanter <jkanter@virginia.edu>
1 sibling, 1 reply; 4+ messages in thread
From: Florian Helmberger @ 2002-01-18 15:14 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: pgsql-admin
Hi.
You should use
ALTER TABLE <table> ADD COLUMN <column> <datatyp>;
instead. Also, take a look at the docs:
http://www.postgresql.org/idocs/index.php?sql-altertable.html
Cheers,
Florian
-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jodi Kanter
Sent: Friday, January 18, 2002 3:56 PM
To: Postgres Admin List
Subject: [ADMIN] adding fields
I need to add a field to an existing table that contains a good amount of
data. Do I need to drop table, recreate, and then reload data to do this? I
cannot seem to find any documentation to say otherwise.
Thanks
Jodi
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: adding fields
@ 2002-01-18 15:20 Jodi Kanter <jkanter@virginia.edu>
parent: Florian Helmberger <f.helmberger@uptime.at>
0 siblings, 0 replies; 4+ messages in thread
From: Jodi Kanter @ 2002-01-18 15:20 UTC (permalink / raw)
To: Florian Helmberger <f.helmberger@uptime.at>; +Cc: pgsql-admin
Thank you. I found this doc just after I sent the email. I appreciate the quick response.
Jodi
----- Original Message -----
From: Florian Helmberger
To: Jodi Kanter
Cc: pgsql-admin@postgresql.org
Sent: Friday, January 18, 2002 10:14 AM
Subject: RE: [ADMIN] adding fields
Hi.
You should use
ALTER TABLE <table> ADD COLUMN <column> <datatyp>;
instead. Also, take a look at the docs:
http://www.postgresql.org/idocs/index.php?sql-altertable.html
Cheers,
Florian
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jodi Kanter
Sent: Friday, January 18, 2002 3:56 PM
To: Postgres Admin List
Subject: [ADMIN] adding fields
I need to add a field to an existing table that contains a good amount of data. Do I need to drop table, recreate, and then reload data to do this? I cannot seem to find any documentation to say otherwise.
Thanks
Jodi
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: adding fields
@ 2002-01-18 15:21 Heather Johnson <hjohnson@nypost.com>
parent: Jodi Kanter <jkanter@virginia.edu>
1 sibling, 0 replies; 4+ messages in thread
From: Heather Johnson @ 2002-01-18 15:21 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; pgsql-admin
Hi Jodi--
No, you shouldn't have to go to that amount of trouble. Try this instead (change the name of the table, the default value, the column name, and the column type to suit your needs):
BEGIN WORK;
LOCK TABLE table_adding_stuff_to IN ACCESS EXCLUSIVE MODE;
ALTER TABLE table_adding_stuff_to ADD COLUMN new_column_name COLUMNTYPE;
ALTER TABLE table_adding_stuff_to ALTER COLUMN new_column_name SET DEFAULT 'default value';
COMMIT WORK;
Then you can do:
BEGIN WORK;
UPDATE table_adding_stuff_to SET new_column_name = 'default value';
COMMIT WORK;
Heather
----- Original Message -----
From: Jodi Kanter
To: Postgres Admin List
Sent: Friday, January 18, 2002 9:55 AM
Subject: [ADMIN] adding fields
I need to add a field to an existing table that contains a good amount of data. Do I need to drop table, recreate, and then reload data to do this? I cannot seem to find any documentation to say otherwise.
Thanks
Jodi
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-01-18 15:21 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-01-18 14:55 adding fields Jodi Kanter <jkanter@virginia.edu>
2002-01-18 15:14 ` Florian Helmberger <f.helmberger@uptime.at>
2002-01-18 15:20 ` Jodi Kanter <jkanter@virginia.edu>
2002-01-18 15:21 ` Heather Johnson <hjohnson@nypost.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox