Bird
0
0

Which of the following is the correct syntax to create a table with a JSON column named data?

easy📝 Syntax Q12 of 15
PostgreSQL - JSON and JSONB
Which of the following is the correct syntax to create a table with a JSON column named data?
ACREATE TABLE mytable (id INT, data JSONB STRING);
BCREATE TABLE mytable (id INT, data JSON);
CCREATE TABLE mytable (id INT, data TEXT JSON);
DCREATE TABLE mytable (id INT, data STRING);
Step-by-Step Solution
Solution:
  1. Step 1: Recall JSON column syntax

    In PostgreSQL, JSON columns are declared with type JSON or JSONB directly.
  2. Step 2: Check each option

    CREATE TABLE mytable (id INT, data JSON); uses correct syntax. Options A, B, and C use invalid or mixed types.
  3. Final Answer:

    CREATE TABLE mytable (id INT, data JSON); -> Option B
  4. Quick Check:

    JSON column syntax = CREATE TABLE mytable (id INT, data JSON); [OK]
Quick Trick: Use JSON or JSONB as column type directly [OK]
Common Mistakes:
  • Using STRING or TEXT with JSON incorrectly
  • Combining JSON with other types in declaration
  • Missing commas or parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes