Practice: Advanced Data Types · PostgreSQL

Ch 2 · PostgreSQL Data Types — card 3 of 4.

Practise PostgreSQL's special types by building a small table of your own with a tags array and a JSONB metadata column. You will insert a few records, then query them by an array element and by a JSON field. A correct answer uses ANY to search the array and picks the right arrow operator depending on whether you want JSON or text back.

  1. Create a table with array and JSONB columns
  2. Insert data with arrays and JSON
  3. Query using array and JSON operators
-- Create table with tags array and metadata JSONB
-- Insert records
-- Query by array element and JSON field