问题
I'd like to change type of column from inet to text. So, I execute:
ALTER TABLE table ALTER COLUMN col TYPE text;
But then I found out that for all values was added mask.
For example:
192.168.100.141 -> 192.168.100.141/32
.
Is it possible to change inet column to text without any changes in this column?
回答1:
Use host() to extract just the ip address:
ALTER TABLE table ALTER COLUMN col TYPE text USING host(col);
来源:https://stackoverflow.com/questions/29101458/postgresql-convert-column-from-inet-to-text