Re: Chante domain type - Postgres 9.2

From: Jan de Visser <jan(at)de-visser(dot)net>
To: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, Patrick B <patrickbakerbr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Chante domain type - Postgres 9.2
Date: 2016-09-26 12:29:25
Message-ID: 96878288-5e4a-8dca-86b8-bfc4b46ea59f@de-visser.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2016-09-26 1:15 AM, Gavin Flower wrote:

> On 26/09/16 17:58, Patrick B wrote:
>> Hi guys,
>>
>> I've got this domain:
>>
>> CREATE DOMAIN public.a_city
>> AS character varying(80)
>> COLLATE pg_catalog."default";
>>
>>
>> And I need to increase the type from character varying(80) to
>> character varying(255).
>>
>> How can I do that? didn't find info about it. I'm using Postgres 9.2
>>
>> Thanks!
>> Patrick
>
> Why not simply use the 'text' data type?
>
> To change the data type on a column you can use:
> ALTER [ COLUMN ] /column_name/ [ SET DATA ] TYPE /data_type/ [ COLLATE
> /collation/ ] [ USING /expression/ ]
>
> see:
> https://www.postgresql.org/docs/9.2/static/sql-altertable.html
>
>
> Note that 9.5 is the latest version of pg, with 9.6 being released
> very soon!
>
>
> Cheers,
> Gavin
>

So I guess the answer to the question is:
- Find all occurrences of a_city
- Change the type of those columns to text (or varchar(80))
- Drop the domain
- Recreate with the proper definition. I agree with Gavin that text is a
better choice. Experience has taught me that server side size constraint
are more trouble than they're worth and that size constraints are better
handled on the client side.
- Change the type of the columns back to the domain.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Sheaver 2016-09-26 12:46:09 Re: Chante domain type - Postgres 9.2
Previous Message hariprasath nallasamy 2016-09-26 10:49:05 Replication slot on master failure