My apologies...
My apologies...
От:
Ken Corey <ken@kencorey.com>
Дата:
My apologies to the lists...in trying to stop my own spam, I spammed you all. This has now been fixed. Again, sorry for any inconvenience. -Ken
changing column data types
От:
"Derek" <derek.mailer@virgin.net>
Дата:
Excuse my ignorance, but I'm used to MySQL and I'm having problems trying to convert a few columns from varchar to numeric. I attempted to get around the problem by creating a new numeric column, but pgsql didn't like it when I tried to copy the varchar column info into the numeric one. Is there a painless way of changing a column type? Thanks in advance for any help offered Derek
Re: changing column data types
От:
ERIC Lawson - x52010 <eric@bioeng.washington.edu>
Дата:
What command did psql complain about, and what was psql's complaint (supposing you're using psql)? The general procedure, AFAIK, if you don't care about getting rid of the old column, is to use ALTER TABLE tablename ADD COLUMN columnname DATATYPE, then UPDATE tablename SET newcolumn=oldcolumn WHERE whatever, 'casting' the data from the old column as needed and appropriate. This seems comparatively painless to me. It gets more painful when the lack of an ALTER TABLE tablename DROP COLUMN columnname is felt, but even then, using pg_dump -s along with a text editor ain't no more than a mosquito bite. On Wed, 21 Feb 2001, Derek wrote: > Excuse my ignorance, but I'm used to MySQL and I'm having problems trying to > convert a few columns from varchar to numeric. I attempted to get around > the problem by creating a new numeric column, but pgsql didn't like it when > I tried to copy the varchar column info into the numeric one. > > Is there a painless way of changing a column type? > > Thanks in advance for any help offered > > Derek > -- James Eric Lawson Research Publications Editor III National Simulation Resource eric@bioeng.washington.edu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Everyday language is a part of the human organism and is no less complicated than it. - Ludwig Wittgenstein (1889-1951) [Tractatus Logico-Philosophicus, 1921]