MySQL: Copy longtext into a JSON column

Viewed 9

In my MySQL database, I have a longtext column that stores a JSON object. I just learned MySQL has a JSON datatype that might give me better encoding.

How can I convert my longtext column into a JSON column?

Specifically, I'd like to first create a new column and copy all the data into it as the JSON format. Then, once I'm sure it worked properly, I can delete my longtext column.

My table is like this:

CREATE TABLE MyTable (
   Id integer primary key,
   Data longtext,
   CreatedDate text,
   ModifiedDate text
)
0 Answers
Related