Q1
True / FalseMySQL supports a JSON data type for storing JSON documents.
MySQL introduced a native JSON data type in version 5.7 to store JSON documents efficiently.
Q2
True / FalseIn MySQL, JSON data type values are stored as plain text strings.
JSON data type values are stored in an optimized binary format, not as plain text strings.
Q3
True / FalseYou can use the -> operator to extract a value from a JSON column in MySQL.
The -> operator in MySQL allows you to extract a value from a JSON column.
Q4
True / FalseThe JSON_ARRAY function in MySQL can be used to create a JSON array from a list of values.
The JSON_ARRAY function is used to create a JSON array from a list of values.
Q5
True / FalseMySQL's JSON_EXTRACT function returns a JSON value directly.
The JSON_EXTRACT function returns a JSON value, which can then be used or converted as needed.
Q6
True / FalseThe JSON_EXTRACT function returns a JSON value, which can then be used or converted as needed.
MySQL automatically validates JSON data stored in a JSON column to ensure it is well-formed.
Q7
True / FalseIn MySQL, you cannot create an index on a specific field within a JSON column.
MySQL allows the creation of indexes on specific fields within a JSON column using generated columns.
Q8
True / FalseThe JSON_MERGE_PATCH function in MySQL replaces the entire JSON document with the new data.
The JSON_MERGE_PATCH function in MySQL modifies only the specified parts of a JSON document, not the entire document.
Q9
True / FalseThe JSON_SCHEMA_VALID function in MySQL can be used to validate JSON documents against a specified schema.
As of MySQL 8.0, there is no JSON_SCHEMA_VALID function; schema validation must be done externally.
Q10
True / FalseMySQL's JSON_SET function can add, update, or remove a value in a JSON document.
The JSON_SET function can be used to add, update, or remove a value in a JSON document by specifying the path and value.
Q22
Multiple ChoiceChoose the correct SQL statement to insert a JSON object into a JSON column.
SQL Code
INSERT INTO users (user_id, user_data)
VALUES (1, '{"name": "John Doe", "age": 30}');
When inserting data into a JSON column, the JSON object must be formatted as a valid JSON string.
Q26
Multiple ChoiceDetermine the correct SQL statement to validate JSON data before inserting into a JSON column.
SQL Code
SET @json = '{"name": "John Doe", "age": 30}';
IF JSON_VALID(@json) THEN
INSERT INTO users (user_id, user_data) VALUES (1, @json);
END IF;
The JSON_VALID function checks whether a string contains valid JSON data, which is crucial for maintaining data integrity in JSON columns.
Q30
Multiple ChoiceWhich SQL statement correctly creates a table with a generated column based on a JSON field?
SQL Code
CREATE TABLE orders (
order_id INT PRIMARY KEY,
order_data JSON,
total_amount DECIMAL(10, 2) AS (JSON_UNQUOTE(JSON_EXTRACT(order_data, '$.total')))
);
A generated column can be created based on a specific field within a JSON column using the JSON_UNQUOTE and JSON_EXTRACT functions.