Trying to convert a text field to a JSON field in Postgres. The field was an IPv6 address those having multiple semicolons eg: "14:eth1:vTA1:::4:"
Trying to run smth like:
ALTER TABLE data ALTER COLUMN ipv6 TYPE jsonb USING ipv6::jsonb;
Results in:
Failed to convert text field to JSON. Details: invalid input syntax for type json DETAIL: Expected end of input, but found ":".
Any clues how to do it properly?
Use to_jsonb rather than::jsonb.
ALTER TABLE data ALTER COLUMN ipv6 TYPE jsonb USING to_jsonb(ipv6);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.