I have to store large amount of HTML data in a database .
I have Googled and found something about the blob
datatype, I checked it and it is working correctly.
I need to store the HTML pages in the tables and need to show them correctly as web pages on demand.
So, which is better for storing large HTML pages, text
or blob
?
BLOB values are treated as binary strings (byte strings). They have the binary character set and collation, and comparison and sorting are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings).
Storing HTML code is fine. But if it is not from trusted source, you need to check it and allow a secure subset of markup only. HTML Tidy library will help you with that. Also, you need to count with a future change in website design, so do not use too much markup, only basic tags.
In MySQL, we can use BLOB datatype to store the files. A BLOB is a binary large object that can hold a variable amount of data. We can represent the files in binary format and then store them in our database. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB.
BLOB, which stands for a Binary Large Object, is a MySQL data type that can store images, PDF files, multimedia, and other types of binary data.
I'd use blob
it's a varbinary and does not do any translation. So your html will come out exactly the same way that it went in.
If you want to search and index that html TEXT
may be a better choice.
In that case make sure you use the proper charset.
I'd recommend UTF8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With