From: | Benjamin Jury <benjamin(dot)jury(at)mpuk(dot)com> |
---|---|
To: | 'MT' <m_tessier(at)sympatico(dot)ca>, GENERAL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: adding fields to a table |
Date: | 2003-06-26 16:34:51 |
Message-ID: | 24DC688F52AAD611B60900096BB0B440015D82C3@chapar.mpuk.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I have a table with a bunch of records already inserted. When
> I want to add or remove fields from the, what I've done is
> produce an sql file, add the fields to the create table
> directive, and add the fields manually to each record to be
> inserted. Then I do an
>
> \i db_name
>
> which destroys all the tables and records and then recreates
> them. I'm wondering if there's a better way. Namely, I alter
> the table using psql, which I know can be done. What I'm not
> sure about is whether altering the table will also alter the
> records, or will the records inserted previous to the alter
> table be out of sync with the table.
You can use ALTER TABLE.
ALTER TABLE <table> ADD [column] column type
Can also rename columns, add constraints, change to NOT NULL, etc.
However you cannot currently remove a column...
ALTER TABLE in SQL COMMANDS at:
http://www.postgresql.com/docs/pdf/7.3/reference-7.3.2-A4.pdf
From | Date | Subject | |
---|---|---|---|
Next Message | DeJuan Jackson | 2003-06-26 16:35:33 | Re: PlPython |
Previous Message | Shridhar Daithankar | 2003-06-26 16:30:52 | Re: [GENERAL] Physical Database Configuration |