JSON Data Type (MySQL)
JSON Data Type (MySQL) is a SQL data type in the MySQL Specific category. MySQL 5.7+: native JSON type with automatic validation and JSON path extraction functions. The syntax is column JSON. It returns jSON document. A typical example: CREATE TABLE products (id INT, attributes JSON); INSERT INTO products VALUES (1, '{"name": "Widget", "price": 9.99, "colors": ["red", "blue"]}'), (2, '{"name": "Gadget", "price": 19.99, "colors": ["green"]}'); -- JSON path queries: SELECT id, attributes->'$.name' AS name, attributes->'$.price' AS price, JSON_EXTRACT(attributes, '$.colors[0]') AS first_color FROM products WHERE JSON_CONTAINS(attributes->'$.colors', '"red"'); -- Multi-value index: ALTER TABLE products ADD INDEX idx_price ((CAST(attributes->'$.price' AS DECIMAL(10,2)))); A close relative is AUTO_INCREMENT, which mySQL auto-generates sequential integer values for this column. Commonly used with PRIMARY KEY. A close relative is ENGINE, which specifies the MySQL storage engine. InnoDB (default) supports transactions and foreign keys. MyISAM is faster for read-heavy. A close relative is LAST_INSERT_ID(), which returns the AUTO_INCREMENT value generated by the most recent INSERT in the current connection.