PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:JSON SELECT
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, JSON data type can be used to store JSON-formatted text.

Q2
True / False

The ->> operator in PostgreSQL JSON queries returns the JSON object.

Q3
True / False

In PostgreSQL, you can use the jsonb data type to store JSON data.

Q4
True / False

The jsonb_each_text function in PostgreSQL returns set of key-value pairs from a JSONB object.

Q5
True / False

PostgreSQL allows indexing of JSONB data using GIN (Generalized Inverted Index).

Q6
True / False

The #>> operator in PostgreSQL can be used to extract a JSON object at the specified path.

Q7
True / False

PostgreSQL's JSON functions do not support JSON path queries.

Q8
True / False

The jsonb_set function in PostgreSQL can be used to update values in a JSONB document.

Q9
True / False

PostgreSQL supports filtering rows based on JSONB array length using the jsonb_array_length function.

Q10
True / False

In PostgreSQL, the jsonb_each function can be used to transform JSONB data into a set of records with keys and values as separate columns.

Q11
Single Choice

Which function in PostgreSQL is used to extract a JSON value as text using a JSON path?

Q12
Single Choice

How can you access the value of a key named "name" from a JSON column called "data" in PostgreSQL?value as text using a JSON path.

Q13
Single Choice

What is the difference between -> and ->> operators in PostgreSQL JSON functions?

Q14
Single Choice

Which of the following SQL statements would you use to retrieve a nested JSON key in PostgreSQL?

SQL Code
SELECT data->'address'->>'city' FROM users;
Q15
Single Choice

Given the following JSON column structure, how would you retrieve all rows where the "active" key is true?

SQL Code
{"id": 1, "active": true}
Q16
Single Choice

How can you convert a JSON array into a PostgreSQL row set using the jsonb_array_elements function?

SQL Code
SELECT jsonb_array_elements(data->'items') FROM table_name;
Q17
Single Choice

How do you use PostgreSQL's JSON functions to extract all "names" from a JSON column that contains an array of objects?

SQL Code
SELECT jsonb_array_elements(data->'items')->>'name' FROM table_name;
Q18
Single Choice

How can you update a specific key within a JSON column in PostgreSQL using the jsonb_set function?

SQL Code
UPDATE table_name SET data = jsonb_set(data, '{key}', '"new_value"') WHERE id = 1;
Q19
Single Choice

Which function would you use to test if a specific key exists within a JSON object in PostgreSQL?

SQL Code
SELECT data ? 'key' FROM table_name;
Q20
Single Choice

In PostgreSQL, which function would you use to aggregate JSON data into a JSON array?

SQL Code
SELECT json_agg(data) FROM table_name;
Q21
Multiple Choice

Which of the following queries correctly selects a specific key from a JSON column?

Q22
Multiple Choice

Which SQL queries correctly extract nested JSON data?

Q23
Multiple Choice

Which SQL queries correctly filter rows based on a JSON key value?

Q24
Multiple Choice

Which SQL queries correctly select all keys from a JSON object in a column?

Q25
Multiple Choice

Which SQL queries correctly select multiple values from a JSON object?

Q26
Multiple Choice

Which SQL queries correctly check if a JSON key exists in a column?

Q27
Multiple Choice

Which SQL queries correctly aggregate data based on a JSON key value?

Q28
Multiple Choice

Which SQL queries correctly select JSON data with conditions on nested objects?

Q29
Multiple Choice

Which SQL queries correctly update a value in a JSON object?

Q30
Multiple Choice

Which SQL queries correctly delete a key-value pair from a JSON object?