Storing HTML in MySQL: blob or text?

后端 未结 2 2041
野趣味
野趣味 2020-12-11 01:46

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 cor

2条回答
  •  眼角桃花
    2020-12-11 02:36

    Seven years have passed since this question was asked. The database industry is converging on using UTF-8 for all text.

    If you use TEXT and make it CHARACTER SET utf8mb4, and you do likewise for all other text fields (except postal_code, country_code, hex, and a few other that are defined to be ascii), then TEXT makes sense.

    But, there is another consideration. If your HTML is an entire page, it makes good sense to put that in a file, not a database table. That way, it can be fetched directly by HTTP. Similarly images and BLOB lead to a argument for where ... is the url of a .jpg file.

提交回复
热议问题