Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert BLOB into VARCHAR in MySQL?

It is in a shared host and I access with Navicat. I have field with BLOB and I want to convert it into VARCHAR. I've tried in the design screen but everything was lost. I backed up.

like image 430
ilhan Avatar asked Dec 25 '11 00:12

ilhan


People also ask

How can I change BLOB data in MySQL?

BLOB Editor is invoked from data grid of any table editor or the result tab of SQL Editor and Visual Query Builder by double clicking of the BLOB field to be edited or with the Edit BLOB link of the field's popup menu. The editor also can be called from BLOB Viewer with the Edit current BLOB button.

Is BLOB a data type in MySQL?

A Binary Large Object ( BLOB ) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.

What is the datatype for BLOB?

A BLOB (binary large object) is a varying-length binary string that can be up to 2,147,483,647 characters long. Like other binary types, BLOB strings are not associated with a code page. In addition, BLOB strings do not hold character data.


2 Answers

try using this, I found it some time ago, you can convert it to char, not to Varchar2 or Varchar, haven't test it yet. Try:

CAST(a.ar_options AS CHAR(10000) CHARACTER SET utf8)

MySQL treat data unique. Hence there is a difference between Blob and Text. Text simply means a text string stored as original, not in binary, whereas a blob is a text string stored as a binary.

like image 192
Luis Nuesi Tejada Avatar answered Nov 11 '22 02:11

Luis Nuesi Tejada


try with the below query

alter table table_name change field_name field_name VARCHAR(1000);
like image 2
ilhan Avatar answered Nov 11 '22 03:11

ilhan