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:

  1. 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.
  2. You can sort & compare TEXT columns based on collation.

BLOB's are just 'binary sequences', and you'll get them 'as is'.

Share:
19,993

Related videos on Youtube

faressoft
Author by

faressoft

Updated on June 04, 2022

Comments

  • faressoft
    faressoft almost 2 years

    What is difference between longblob and longtext in mysql?

    What should I use to save a long topic ?

  • evilone
    evilone about 13 years
    what bad about that? google is my friend and I can learn myself too doing google search and helping other people :)
  • Admin
    Admin about 13 years
    There'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
    Francisco Presencia over 11 years
    Try 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
    Cristian Vrabie about 11 years
    convert 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
    Vishal Kumar Sahu about 7 years
    For example? You statement creates mystery.
  • texas-bronius
    texas-bronius about 5 years
    I 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
    TommyAutoMagically over 3 years
    @SahuVKumar: I'd assume that it's safe to put text data into either BLOB or TEXT types. However, my guess is that putting binary data into BLOB and TEXT types might yield different results.

Related