MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:JSON Data Type
Current Quiz Count:30
Progress
0%
Q1
True / False

MySQL supports a JSON data type for storing JSON documents.

Q2
True / False

In MySQL, JSON data type values are stored as plain text strings.

Q3
True / False

You can use the -> operator to extract a value from a JSON column in MySQL.

Q4
True / False

The JSON_ARRAY function in MySQL can be used to create a JSON array from a list of values.

Q5
True / False

MySQL's JSON_EXTRACT function returns a JSON value directly.

Q6
True / False

The JSON_EXTRACT function returns a JSON value, which can then be used or converted as needed.

Q7
True / False

In MySQL, you cannot create an index on a specific field within a JSON column.

Q8
True / False

The JSON_MERGE_PATCH function in MySQL replaces the entire JSON document with the new data.

Q9
True / False

The JSON_SCHEMA_VALID function in MySQL can be used to validate JSON documents against a specified schema.

Q10
True / False

MySQL's JSON_SET function can add, update, or remove a value in a JSON document.

Q11
Single Choice

What version of MySQL introduced the JSON data type?

Q12
Single Choice

Which function is used to create a JSON array in MySQL?

Q13
Single Choice

Which operator is used to extract a value from a JSON column in MySQL?

Q14
Single Choice

What does the JSON_UNQUOTE function do in MySQL?

Q15
Single Choice

Which function is used to merge two JSON documents in MySQL?

Q16
Single Choice

Which MySQL function is used to search for a value within a JSON document?

Q17
Single Choice

How can you index a specific field within a JSON column in MySQL?

Q18
Single Choice

Which function is used to modify parts of a JSON document in MySQL without affecting the entire document?

Q19
Single Choice

What does the JSON_REMOVE function do in MySQL?

Q20
Single Choice

Which MySQL function converts a JSON document to a string?

Q21
Multiple Choice

Identify the correct SQL statement to create a table with a JSON column.

SQL Code
CREATE TABLE users (
 user_id INT PRIMARY KEY,
 user_data JSON
);
Q22
Multiple Choice

Choose 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}');
Q23
Multiple Choice

Determine the correct SQL statement to update a specific field in a JSON column.

SQL Code
UPDATE users
SET user_data = JSON_SET(user_data, '$.age', 31)
WHERE user_id = 1;
Q24
Multiple Choice

Which SQL statement correctly creates an index on a JSON column's specific field?

SQL Code
CREATE INDEX idx_user_age
ON users((JSON_UNQUOTE(JSON_EXTRACT(user_data, '$.age'))));
Q25
Multiple Choice

Select the correct SQL statement to query a specific field in a JSON column.

SQL Code
SELECT user_id, JSON_UNQUOTE(JSON_EXTRACT(user_data, '$.name')) AS name
FROM users;
Q26
Multiple Choice

Determine 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;
Q27
Multiple Choice

Which SQL statement correctly merges two JSON objects in a JSON column?

SQL Code
UPDATE users
SET user_data = JSON_MERGE(user_data, '{"location": "New York"}')
WHERE user_id = 1;
Q28
Multiple Choice

Select the correct SQL statement to delete a specific key from a JSON object in a JSON column.

SQL Code
UPDATE users
SET user_data = JSON_REMOVE(user_data, '$.age')
WHERE user_id = 1;
Q29
Multiple Choice

Determine the correct SQL statement to extract a nested JSON object from a JSON column.

SQL Code
SELECT JSON_UNQUOTE(JSON_EXTRACT(user_data, '$.address.city')) AS city
FROM users
WHERE user_id = 1;
Q30
Multiple Choice

Which 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')))
);