Firebird 2.5.2 change blob subtype

筅森魡賤 提交于 2019-12-10 13:58:59

问题


Is there a posibility to change the SUBTYPE of a BLOB field ?

I have a BLOB with SUBTYPE BINARY an need to change it to SUBTYPE TEXT, because i get some strange Characters into the BLOB and in a BLOB with SUBTYPE TEXT i don't have this Problem


回答1:


Directly altering the subtype of a blob column is not possible (attempts to do this will give the error "Cannot change datatype for column BLOBCOLUMN. Changing datatype is not supported for BLOB or ARRAY columns.")

You will need to

  1. Add a new column with an explicit character set (I am assuming windows 1252 based on your comments)

    ALTER TABLE table_name
      ADD blobcolumn_new BLOB SUB_TYPE TEXT CHARACTER SET WIN1252
    
  2. Copy the data from the old column to the new column:

    UPDATE table_name SET blobcolumn_new = blobcolumn
    
  3. Drop the old column

    ALTER TABLE table_name
      DROP blobcolumn
    
  4. Rename the new column

    ALTER TABLE table_name
      ALTER COLUMN blobcolumn_new TO blobcolumn
    


来源:https://stackoverflow.com/questions/24818681/firebird-2-5-2-change-blob-subtype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!