How to convert VARCHAR to BLOB in MySQL? - mysql

I need to convert a MySQL column to use BLOB instead of VARCHAR that's used to store encrypted data.
I can find all sorts of posts of how to convert from BLOB to VARCHAR, but cannot find anything for going from VARCHAR to BLOB.
Can someone tell me how to do this?

I figured it out by using:
alter table users change email email blob

Related

Converting varbinary to longblob in MySQL

We are storing data in an Innodb table having varbinary column. However, our data size requirement has grown to over 1 MB and hence I converted the column to longblob.
alter table mytable modify column d longblob;
Everything seems to be working as expected after I converted the column. However, I like to know from people who have done it earlier if anything more is required other than just converting column as shown above, especially
is there any MySQL / MariaDB version specific issues with longblob that I should take care of. There is no index on the column.
We use mysqldump to take regular backup. Do we need to change anything since the blob storage mechanism seems to be different than varbinary.
Any other precautions/suggestion.
Thank you for your guidance

MySQL Workbench reading out a BLOB containing a date

I have a table with questions in them. They have a date column with as type a BLOB.
Is it possible for MySQL to read out the BLOB as I can't convert it to a normal DATE type
Without knowing why you have a DATE stored in a BLOB field have you tried using the STR_TO_DATE function?
SELECT STR_TO_DATE(your_blob_field,'%d,%m,%Y');

Aes_decrypt on varchar column?

I made a small form for a website which stored the formdata with Aes_encrypt. The database that was used accidentally set the column type to varchar, and the collation to utf-8. Now when I run aes_decrypt, I get null as a result. Is there any way to still decrypt the data? Or is it now completely useless?
Thanks!

convert column to varchar in oracle which is mysql longtext

i have a insert statement pulling data from db link.
insert into table (a,b,c)
select a,b,c from table#mysqldb;
here column c is long type in mysql and in oracle its varchar
i tried to cast as varchar, substr(c, 1,2400), UTL_RAW.CAST_TO_VARCHAR2,dbms_lob.substr
none of them are working on oracle side.
tried cast on mysql read part no use.
Can someone tell me how to do this. Here Iam trying to convert long to varchar. we cannot load as clob as this table is used in many places and we cannot change things at so many places
Thanks.
i had to convert the target column to clob to handle this scenario

can Mysql or sqlite Blob data type store varchar data in it?

Can one anyone provide any information on whether can we store normal text data(varchar) in mysql or sqlite Blob data type
You can store any binary data in a blob. This would include both ascii and unicode text. However, you would need to explicitly interpret this as text in your code since an SQL interface would have no idea what type of data was stored inside its binary field.
Why would you want to use this rather than a normal varchar or text field?
A BLOB is just a bunch of bytes -- no hindrance no help dealing with them in any way; a VARCHAR is known to be text so such things as character encoding and collation come into play. So, store bunches of bytes (e.g. images) as BLOBs, bunches of text as TEXT or VARCHAR!
in mysql you can insert text/varchar in a blob data type.
blob can support binary data. meaning that non binary or binary data are also supported in mysql.
text/varchar can be indexed but not for blob.
further readings here
SQLite uses manifest typing, so you can put any type of data in any type of column, actually. Then you'll have to interpret the returned data yourself, just like everyone pointed out for MySQL.