-1

I have an application where I am going to store the JSON string in MySql database through Eclipselink JPA. The JSON string can be of any length. Most of the time a String from a JSON file of length around 200 to 300 lines. What is the best way to store the string? To use varchar or Blob? Please provide an example if any.

Abhijit
  • 175
  • 5
  • 16

2 Answers2

1

You should not save it as a BLOB, as it is primarily used for image data or other binary data... Use Varchar() or use TEXT which has a size of 65535 characters if you are unsure about how many characters you might need to store..

There was a thread previously discussing WHEN to use varchar or text: Thread

Community
  • 1
  • 1
DTH
  • 1,133
  • 3
  • 16
  • 36
1

To store text - use a TEXT column (or even a LONGTEXT), blobs are for binary.

Also if you're on Mysql 5.7+ - there's now a JSON data type, which is checked for being a correct json, stored more efficiently and have pretty manipulation methods

Vasfed
  • 18,013
  • 10
  • 47
  • 53