6
I’m using a database that has a field called: status: boolean
, but I want to store in it the values of the radio button (0,1,2) so I need to change to integer
.
I’ve tried to:
ALTER TABLE OS ALTER COLUMN STATUS TYPE BOOLEAN USING (trim(STATUS)::integer);
ALTER TABLE OS ALTER COLUMN STATUS TYPEINTEGER;
But you made these mistakes:
ERROR: function pg_catalog.btrim(boolean) does not exist
LINE 1: ... TABLE OS ALTER COLUMN STATUS TYPE INTEGER USING (trim(STATU...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: column "status" cannot be cast automatically to type integer
HINT: You might need to specify "USING status::integer".
I have how to solve this without having to create the table again?
No, switch to smallint .
– Marco Souza
Only creating table a again?
– WSS
or you can create an https://www.postgresql.org/docs/9.1/static/datatype-enum.html I think in your case an Enum ... you can make an alter table
– Marco Souza