sql >> Base de Datos >  >> RDS >> PostgreSQL

postgreSQL altera el tipo de datos de la columna a la marca de tiempo sin zona horaria

Si create_time es de tipo TEXTO con valor de fecha válido, será más fácil continuar con el cambio de la siguiente manera (se recomienda hacer primero un volcado de tabla como respaldo):

-- Create a temporary TIMESTAMP column
ALTER TABLE AB ADD COLUMN create_time_holder TIMESTAMP without time zone NULL;

-- Copy casted value over to the temporary column
UPDATE AB SET create_time_holder = create_time::TIMESTAMP;

-- Modify original column using the temporary column
ALTER TABLE AB ALTER COLUMN create_time TYPE TIMESTAMP without time zone USING create_time_holder;

-- Drop the temporary column (after examining altered column values)
ALTER TABLE AB DROP COLUMN create_time_holder;