Importing Data
Learn strategies to import data in JSON or XML format to MySQL.
We'll cover the following
In SQL, data is naturally stored in a tabular form. With the two data types JSON and TEXT, MySQL allows storing data encoded in JSON or XML without enforcing a tabular format. As we may not only want to store JSON/XML in a single field using the two mentioned data types, MySQL also offers ways to import JSON/XML files directly. Before looking at these capabilities, let’s look at the two data types, JSON and TEXT, about storing JSON and XML, respectively.
Importing JSON data
JSON is MySQL’s data type that natively supports and provides efficient access to JSON documents. While we could store JSON documents as strings using the TEXT data type, JSON provides two crucial advantages over TEXT. Firstly, storing JSON documents in a column of type JSON automatically validates the input and produces an error for invalid documents:
Get hands-on with 1400+ tech skills courses.