| From: | Marc SCHAEFER <schaefer(at)alphanet(dot)ch> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Increasing Table Column Size in 7.0 Syntax |
| Date: | 2000-11-01 19:15:01 |
| Message-ID: | Pine.LNX.3.96.1001101201256.829B-100000@defian.alphanet.ch |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, 1 Nov 2000, Richard Poole wrote:
> Long answer: create a new table with the same columns, except give the
> one you want to change its new size. Then copy all the data across
I just did it (for another reason)
To alter a table (remove, or change columns)
# Copy the data
CREATE TABLE temp AS SELECT * FROM distributors;
# Drop and recreate the table
DROP TABLE distributors;
CREATE TABLE distributors (did DECIMAL(3) DEFAULT 1,
name VARCHAR(40) NOT NULL);
# Get back the data
INSERT INTO distributors SELECT * FROM temp;
# Drop the temporary table.
DROP TABLE temp;
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Poole | 2000-11-01 19:16:16 | Re: database and table listing |
| Previous Message | Stephen Patterson | 2000-11-01 19:00:12 | database and table listing |