Re: int4 to varchar length (pgadmin3) issue

Поиск
Список
Период
Сортировка
От Andreas
Тема Re: int4 to varchar length (pgadmin3) issue
Дата
Msg-id 45036CB9.3040404@gmx.net
обсуждение исходный текст
Ответ на Re: int4 to varchar length (pgadmin3) issue  (Richard Broersma Jr <rabroersma@yahoo.com>)
Список pgsql-novice

Richard Broersma Jr schrieb:
>> iow, i want to limit the the newly converted varchar
>> revision to 2 characters, but can't due to the grayed
>> out boxes in pgadmin3.
>
> I saw this example at:
> http://www.postgresql.org/docs/8.1/interactive/sql-altertable.html
>
> ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);
>
> This should do what you want.

Actually it is not.
This constraint enforces the length of zipcodes to exactly 5 chars.

operationsengineer1 rather wants an upper limit of 2 chars but not
exactly 2 everywhere.
Theres no need for a separate constraint as a comumn declaration of
varchar(2) would do.

operationsengineer1's problem is that pgAdmin lets him change the data
type of the column but not the size of the resulting varchar. The size
field in the form is inactive and empty.
Thats a wee bit silly of pgAdmin because it lets you alter the size of
varchar columns that are created as varchar in the first place but not
of columns that got converted to varchar.

But thanks to your link to the documentation I found the solution.

ALTER TABLE table1 ALTER COLUMN revisioninfo TYPE varchar(2);


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

Предыдущее
От: Andreas
Дата:
Сообщение: Re: int4 to varchar length (pgadmin3) issue
Следующее
От:
Дата:
Сообщение: Re: Progress and Questions