From: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu> |
---|---|
To: | postgres-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: ALTERING A TABLE |
Date: | 2000-06-01 19:11:05 |
Message-ID: | 20000601141105.A20587@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Jun 01, 2000 at 11:00:09AM -0700, Steve Wampler wrote:
> Ron Peterson wrote:
> >
> >
> > You can't use ALTER TABLE to change a field's data description. You'll
> > have to make a new table. Then use SELECT INTO to move your data. Then
> > DROP TABLE oldtable. Then ALTER TABLE tablename RENAME TO newname.
>
> Would this really work? According to the docs, SELECT INTO creates a
> new table (which must not yet exist). So this new table
> would have the same field data descriptions as the original, right?
>
> Is the documentation wrong?
Document's right, Ron mis-spoke (mis-typed?) That should be "INSERT INTO
... SELECT ... FROM"
The tricky part is doing the select in such a way that the data gets
converted on the way into the new table. This shouldn't be a problem
for text to text, but if you where changing the type of a column, you'd
need to cast it on the way.
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-06-01 19:24:15 | Re: btree index and max() |
Previous Message | Diego Schvartzman | 2000-06-01 19:01:31 | Re: CREATE USER |