What is the difference between longblob and longtext in mysql?
19,993
Solution 1
BLOBs are for Binary Large Objects. If you're storing binary data in your DB, then BLOB would be the table type you want. Otherwise.. longtext.
In your case longtext.
Solution 2
BLOB and TEXT are basically identical, except that TEXT fields have character set translation rules applied. BLOB fields do not. So with BLOB what you put in is what you get. With TEXT, what you put may not be what you get out.
Solution 3
You can use collation & character sets on TEXT
columns, which would mean that:
- If you specify a different charset for a connection than the
TEXT
column is (for instance,latin1
column,utf-8
requested), MySQL will convert the contents to the required charset. - You can sort & compare
TEXT
columns based on collation.
BLOB
's are just 'binary sequences', and you'll get them 'as is'.
Related videos on Youtube
Author by
faressoft
Updated on June 04, 2022Comments
-
faressoft almost 2 years
What is difference between longblob and longtext in mysql?
What should I use to save a long topic ?
-
evilone about 13 yearswhat bad about that? google is my friend and I can learn myself too doing google search and helping other people :)
-
Admin about 13 yearsThere's nothing bad about it, I wanted to post exactly the same but you beat me to it with a few seconds haha! +1
-
Francisco Presencia over 11 yearsTry to cite your sources, tell the user to google it in this case and maybe downvote the OP if deserved. Though +1 for this.
-
Cristian Vrabie about 11 yearsconvert the contents is a good hint at something that people generally don't mention when explaining the difference between BLOB and TEXT: performance. Sometimes both might be suitable for some data so it would be wise to pick the one with the least performance penalty.
-
Vishal Kumar Sahu about 7 yearsFor example? You statement creates mystery.
-
texas-bronius about 5 yearsI think this is what I am experiencing, and it may help: A specific example where this occurs is a Drupal longtext field with UTF-8 Unicode specified throws PDO Exception when a higher unicode emoji ("💕" in this case) is inserted, but the same database with a LONGBLOG field accepts it just fine.
-
TommyAutoMagically over 3 years@SahuVKumar: I'd assume that it's safe to put text data into either
BLOB
orTEXT
types. However, my guess is that putting binary data intoBLOB
andTEXT
types might yield different results.