简体   繁体   English

在mysql中将文本转换为blob

[英]Convert text to blob in mysql

I want to convert a "text" field to "blob" in mysql 5. Will the data be affected in any way if I simply run 我想在mysql 5中将“text”字段转换为“blob”。如果我只是运行,数据是否会受到任何影响

alter table <table> change <col> <col> blob; alter table <table> change <col> <col> blob;

I tried it and it worked with no problems, I was just wondering if there's something I may be missing or should take special care of. 我尝试了它并没有任何问题,我只是想知道是否有一些我可能会遗漏或应该特别照顾。

You shouldn't have any problems. 你不应该有任何问题。 The main differences between blob and text are in the way they are sorted (eg numeric v lexicographic). blob和text之间的主要区别在于它们的排序方式(例如,数字v词典)。 They hold the same size of data and there doesn't seem to be any fiddling (eg with carriage returns / newlines). 它们拥有相同大小的数据,似乎没有任何摆弄(例如,回车/换行)。

Useful page in the manual 手册中的有用页面

http://dev.mysql.com/doc/refman/5.0/en/blob.html http://dev.mysql.com/doc/refman/5.0/en/blob.html

ALTER TABLE myTableName MODIFY COLUMN columnName BLOB;

Yup you shouldn't face any problem except sorting. 是的,除了排序,你不应该遇到任何问题。

As mysql will convert "text" to binary data when changed to "blob" and vice versa. 因为当更改为“blob”时,mysql会将“text”转换为二进制数据,反之亦然。

you can simply get 你可以简单地得到

String str = resultSet.getString(columnIndex) 
// or 
byte[] byteArr = resultSet.setBytes(columnIndex).
String str = new String(byteArr );

You can simply make a new dump and compare it against your backup. 您只需创建一个新转储并将其与备份进行比较即可。 Use WinMerge , KDiff3 or your tool of choice. 使用WinMergeKDiff3或您选择的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM