Now I'm developing application that uses hibernate + postgresql to persist data. We need to store a number of serializable HashMaps, so LOB (oid) was used for this purpose. But due to some problems with oid deletion in postgresql we decide to store this data as bytea instead of oid. So the question is that what is the best way to alter column type from oid to bytea with retaining old data? If someone can give a working script/solution for such a data transition it will be great.
Thank you in advance.
lobs are probably the wrong solution for serializable hash maps unless you need to do seeking with offsets. Bytea is cleaner. The problem is that you will probably have to have some down time to switch things over.
What I would probably do is create a new column and copy the data over, and then unlink, and then drop the old column. Then run appropriate vacuum jobs.