1
I need to change the column type of a table
I’m using the following code:
ALTER TABLE cadastro_remetente ALTER COLUMN ssl_smtp DROP DEFAULT;
ALTER TABLE cadastro_remetente ALTER COLUMN ssl_smtp SET DEFAULT FALSE;
ALTER TABLE cadastro_remetente ALTER ssl_smtp TYPE bool USING CASE WHEN ssl_smtp='TRUE' THEN TRUE ELSE FALSE END;'
smtp is currently Character Varying
is returning me the following error:
ERROR: check restriction "ssl_smtp" was breached by some record
********** Error **********
ERROR: Check constraint "ssl_smtp" breached by record SQL state: 23514
All records are TRUE or FALSE
someone can help me in this?
If the column is Boolean, the values accepted are,
t
/f
,true
/false
,1
/0
. I don’t understand thessl_smtp DROP DEFAULT
nor the CASE. You want to change the column type and keep the values?– rray
Check by pgAdmin if there is a column in this table with a Constraint/constraint.
– rray
CONSTRAINT pk_registration PRIMARY KEY (id). currently the table ssl_smtp is Character Varying and I want to change to Boolean, and that’s what I’m not getting.....
– HimorriveL
Maybe there’s some
check
or Domain in the columnssl_smtp
of a verified.– rray
Show the table structure with
\d cadastro_remetente
on psql– Clodoaldo Neto
i searched on the internet and from what I read it will be necessary to create a new table... pass the information to there, delete the old table and then rename the new table...
– HimorriveL