Re: alter varchar ->timestamp

From: "Guillermo E(dot) Villanueva" <guillermovil(at)gmail(dot)com>
To: Daymel Bonns Solís <dbonne(at)uci(dot)cu>, Rodrigo Gonzalez <listas(at)estrads(dot)com(dot)ar>
Cc: pgsql-es-ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: alter varchar ->timestamp
Date: 2012-10-12 15:32:41
Message-ID: CANm+PCBjUa4XwsnL6tiekmkHbprYUM0WJfovY9pPcfdTM9+0jQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Buenísimo, muchas gracias, no sabía que se podía instruir al ALTER de como
hacer la modificación.
MUCHAS GRACIAS
Guillermo Villanueva

El 12 de octubre de 2012 11:49, Daymel Bonns Solís <dbonne(at)uci(dot)cu> escribió:

> On 10/12/2012 10:40 AM, Rodrigo Gonzalez wrote:
>
>> On Fri, 12 Oct 2012 11:12:25 -0300
>> "Guillermo E. Villanueva" <guillermovil(at)gmail(dot)com> wrote:
>>
>> Hola amigos,
>>> tengo una columna de una tabla de tipo varchar(10)
>>> la tabla tiene mas de 1millón de filas esa columna por ahora está en
>>> null para todas las filas.
>>> Resulta que el tipo correcto de datos es date, es posible modificarlo
>>> teniendo en cuenta que está todo nulo? *(no puedo cambiar el orden de
>>> las columnas)*
>>>
>>> Si intento:
>>> alter table nacer.historicotemp alter column fum type date
>>> me da:
>>> ERROR: la columna «fum» no puede convertirse al tipo date
>>>
>>> ********** Error **********
>>>
>>> ERROR: la columna «fum» no puede convertirse al tipo date
>>> SQL state: 42804
>>>
>>> No me digan que tendré que crear de nuevo la tabla!?!?
>>>
>> No, no tenes que crearla de nuevo...tenes que usar using
>>
>> postgres=# alter table test alter column texto type date using
>> (texto::date);
>> ALTER TABLE
>> postgres=# \d test
>> Table "public.test"
>> Column | Type | Modifiers
>> --------+------+-----------
>> texto | date |
>>
>> En tu caso cambiar solo texto por null, quedaría:
>
> alter table nacer.historicotemp alter column fum type date using
> (null::date);
>
>
> --
> -- --
> / \~~~/ \ . o O ( http://postgresql.uci.cu )
> ,----( oo )
> / \__ __/
> /| )\ |(
> ^ \ /__\ /\ |
> |__| |__|-"
>
>
> 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS
> INFORMATICAS...
> CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION
>
> http://www.uci.cu
> http://www.facebook.com/**universidad.uci<http://www.facebook.com/universidad.uci>
> http://www.flickr.com/photos/**universidad_uci<http://www.flickr.com/photos/universidad_uci>
>

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Leonardo Vega 2012-10-12 19:17:05 Consulta
Previous Message Daymel Bonns Solís 2012-10-12 14:49:27 Re: alter varchar ->timestamp