How to set a blob field to NULL - mysql

I have a table with a BLOB field that I sometimes want to set to NULL. If I edit a row in phpMyAdmin, I can set non-blob fields to NULL, but all I can do with a BLOB field is upload a file. If the field already has a value, the only way I have found to NULL it is to type in an SQL query. This makes each row update a two-step process, which makes it more error-prone (not to mention irritating).
I haven't found anything about this in the manual. If it makes a difference, I'm using phpMyAdmin version 3.3.8.1.

I also have been perplexed by the inability to set BLOB columns to NULL in phpMyAdmin. Luckily this seems to have been recently fixed: phpMyAdmin 3.4.1 happily lets you set BLOB columns to NULL.

Related

How To make varbinary type maximum in mysql

I have Question, in my application needed setting type for varbinary in my database i have 8 field name using varbinary(max), like as using sql server varbinary(max) but i already did varbinary(60000) that's is not problem database still running fine, but after i tried to using varbinary(60000) for each field name, showing error like below
can someone help me for solving this problem i have tried to setting ROW_FORMAT to COMPRESSED,DYNAMIC but still cannot set varbinary(60000) for each field name.
Thanks in advance
As the error message says, MySQL has row size limit of 65535. You can change the columns to use TEXT datatype so you won't hit the row size limit.
See MySQL documentation - Limits on Table Column Count and Row Size for more info.

Why/how am I able to exceed the configured length of a varchar in MySQL? [my mistake, I can't]

[Edit: my mistake, read the wrong column for the type, the one I'm inserting into is LONGTEXT, not varchar(190)]
I am working with an application that stores the majority of its information in a MySQL database (MySQL server 5.7). One particular value I'm looking at has a 255 character limit enforced by the GUI but, when I looked at that column in the table where it's stored, it's set to varchar(190). I confirmed that I can enter 255-character values in the GUI and that they are not truncated, as I expected.
How can a varchar(190) column store >190 characters? Are there any consequences to doing it this way?
I read 11.4.1 The CHAR and VARCHAR Types and it states that anything over the limit should be truncated.
The answer is that I can't. Misread the column types because that column is varchar(255) when the application builds the schema in PostgreSQL. It's longtext* in MySQL, which explains why I was able to get past the 190 characters. I tried inserting my 230 char test string into the varchar(190) column and it throws an error, as expected.
Need more coffee.
*not sure why longtext, when the application GUI limits input to 255 characters, but I'll need to ask the people who built it.

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!

Why does imported MySQL dump show some column value as BLOB?

I imported a MySQL table dump from my server to my local system. I am using phpMyAdmin to view my local MySQL databases. The column that held emails shows as BLOB - instead of actual email.
When I press on "edit" it shows correct emails, but not on listing.
I am totally confused as why this happens. Can anyone suggest solution?
BLOB data type is meant to store arbitrary binary data (Binary Large OBject = BLOB), for example an image or another document. It does not make sense to show the value as-is. It would look the same as viewing an image in a text editor.
You have several options, depending on the version of phpMyAdmin you are using - which I unfortunately do not know.
Make phpMyAdmin show BLOB values by default.
Show BLOB values for a complete result set.
These two possibilities are covered by an already asked question.
But basically, this is just fighting symptoms instead of curing the disease. The question is: Why did you chose the email field to be a BLOB? Basically, a VARCHAR is enough. I do not know the MySQL version you are running, but since MySQL 5.0.3, a VARCHAR can be as large as 65k byte.
ALTER TABLE
`table`
CHANGE
`email` `email` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
The query above changes the field email to a VARCHAR(255). Pay attention to the length you like to use, and to the character set and collation. But UTF-8 should be very fine in this case.
It shows the text of "Blob" as a placeholder as the blob datatype (which is the datatype that your emails are stored in) is vastly variable in size. For large Blob sizes, if the data were displayed, it could take up 100s + screens to display.

MySQL CharacterSet Conversion of a column will impact the existing values or not

I use MySQL 5.1 version
I have a MySQL table 'server_info' which has 2 columns 'server_id' as well as 'server_details' of which the character set of 'server_details' column was 'latin1' and i have 100 rows of data in the table. Now, I got some error while updating the table with some specific string values. Error message follows
'Incorrect String value for column server_details....'
Which i realized that was due to the different character set.
So i decide to change my character to 'utf-8' to support the new string as well.
If i change the character set will the existing data affected?
what will happen to the existing data?
What all things i should be careful about before doing this
conversion?
Is this conversion, the right fix for my problem?
While i checked in MySQL 5.6 version The conversion gave me a messgage that '100 rows are affected' Does that mean existing data also got converted to the new character set?
If Yes, Will this be the same behaviour i can expect in MySQL 5.1
version also?
If you change the Character Set there will be no impact on the existing values. Because during the insertion the data lost ( or doesn't aware of) some extra information about the Character Set.
To fix this problem you have to convert the text manually.