PostgreSQL - JSON and JSONBWhich 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);Check Answer
Step-by-Step SolutionSolution:Step 1: Recall JSON column syntaxIn PostgreSQL, JSON columns are declared with type JSON or JSONB directly.Step 2: Check each optionCREATE TABLE mytable (id INT, data JSON); uses correct syntax. Options A, B, and C use invalid or mixed types.Final Answer:CREATE TABLE mytable (id INT, data JSON); -> Option BQuick 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 incorrectlyCombining JSON with other types in declarationMissing commas or parentheses
Master "JSON and JSONB" in PostgreSQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PostgreSQL Quizzes Aggregate Functions and GROUP BY - GROUPING SETS for multiple groupings - Quiz 5medium Aggregate Functions and GROUP BY - String aggregation with STRING_AGG - Quiz 9hard Common Table Expressions - Why CTEs matter in PostgreSQL - Quiz 5medium Joins in PostgreSQL - INNER JOIN execution - Quiz 1easy Joins in PostgreSQL - LATERAL join for correlated subqueries - Quiz 12easy Set Operations and Advanced Queries - Returning modified rows with RETURNING - Quiz 4medium Set Operations and Advanced Queries - Conditional INSERT with ON CONFLICT - Quiz 11easy Views and Materialized Views - Views with CHECK OPTION - Quiz 7medium Views and Materialized Views - REFRESH MATERIALIZED VIEW - Quiz 4medium Window Functions in PostgreSQL - NTILE for distribution - Quiz 5medium