[英]MySQL Blob to Text (data and datatype)
I have a mysql database that holds content as a blob, for whatever reason those developers chose to use a blob is out of my control. 我有一个mysql数据库,它将内容保存为blob,无论出于何种原因,这些开发人员选择使用blob都是我无法控制的。 Is it possible to convert the data to text and the data type to text? 是否可以将数据转换为文本,将数据类型转换为文本?
have you tried the alter table command ? 你试过alter table命令吗?
alter table mytable change mycolumn mycolumn text;
from http://forums.mysql.com/read.php?103,164923,167648#msg-167648 it looks like you can use CAST. 从http://forums.mysql.com/read.php?103,164923,167648#msg-167648看起来你可以使用CAST。
you could create a new (TEXT) column, then fill it in with an update command: 您可以创建一个新的(TEXT)列,然后使用更新命令填充它:
update mytable set myNewColumn = CAST(myOldColumn AS CHAR(10000) CHARACTER SET utf8)
Converting the field from blob to text truncates all characters > 127. In my case we have lots of european characters, so this was not an option. 将字段从blob转换为文本会截断所有字符> 127.在我的情况下,我们有很多欧洲字符,所以这不是一个选项。 Here's what I did: 这是我做的:
Not exactly straightforward but it worked and no data loss. 不完全简单,但它工作,没有数据丢失。 I'm using Version: '5.1.50-community' 我正在使用版本:'5.1.50-community'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.