Re: Finding Max Value in a Row

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Finding Max Value in a Row
Дата
Msg-id 2250.1336965103@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Finding Max Value in a Row  (Carlos Mennens <carlos.mennens@gmail.com>)
Ответы Re: Finding Max Value in a Row  (Samuel Gendler <sgendler@ideasculptor.com>)
Re: Finding Max Value in a Row  (Dmitriy Igrishin <dmitigr@gmail.com>)
Список pgsql-sql
Carlos Mennens <carlos.mennens@gmail.com> writes:
> I'm not understanding why I'm not able to change this column type from
> char to integer?

> forza=# ALTER TABLE customers
> ALTER COLUMN cust_id TYPE integer;
> ERROR:  column "cust_id" cannot be cast to type integer

Try "ALTER ... cust_id TYPE integer USING cust_id::integer".

If you don't specify a USING expression, the command requires an
implicit coercion from one type to the other, and there is none from
char(n) to int.  You can force it with an explicit coercion, though.

It strikes me that "cannot be cast" is a poor choice of words here,
since the types *can* be cast if you try.  Would it be better if the
message said "cannot be cast implicitly to type foo"?  We could also
consider a HINT mentioning use of USING.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Carlos Mennens
Дата:
Сообщение: Re: Finding Max Value in a Row
Следующее
От: Steven Crandell
Дата:
Сообщение: Re: syncing - between databases