Ho un campo che è INTEGER NOT NULL DEFAULT 0 e ho bisogno di cambiarlo in bool.Postgres Alter Column Integer to Boolean
Questo è quello che sto usando:
ALTER TABLE mytabe
ALTER mycolumn TYPE bool
USING
CASE
WHEN 0 THEN FALSE
ELSE TRUE
END;
Ma io sono sempre:
ERROR: argument of CASE/WHEN must be type boolean, not type integer
********** Error **********
ERROR: argument of CASE/WHEN must be type boolean, not type integer
SQL state: 42804
Qualche idea?
Grazie.
la risposta accettata è meglio perché * non * fare affidamento su tipo-casting. Ad esempio, questo metodo fallisce con "impossibile eseguire il cast di tipo smallint su boolean". –