Re: alter varchar ->timestamp

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

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.flickr.com/photos/universidad_uci

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Guillermo E. Villanueva 2012-10-12 15:32:41 Re: alter varchar ->timestamp
Previous Message Rodrigo Gonzalez 2012-10-12 14:40:29 Re: alter varchar ->timestamp