JSONB and Arrays
Part of the PostgreSQL course
Some data refuses to sit still in columns. A products table where laptops have a RAM size, keyboards have a switch type and monitors have a diagonal, and next month somebody adds candles. You can add a column per attribute and watch the table grow ninety mostly-null columns, or you can invent a key-value side table and hand-roll a query language for it.
The same problem shows up smaller with lists. A post has tags. Three of them, usually. A whole join table for that is often more machinery than the problem deserves, and Postgres will happily let a column hold an array. ...
Want to learn PostgreSQL JSONB and Arrays in a real environment?
Click below, get a fresh Linux box with PostgreSQL ready to go, and work through JSONB and Arrays hands-on with an AI tutor that knows your code.
Start this lessonJSONB and ArraysWhat you'll learn
- JSONB column
- -> operator
- ->> operator
- @> contains operator
- GIN index on jsonb
- Text[] and integer[] arrays
- ANY()
- Unnest
Read this lesson in your language
All lessons in this course
14 lessons- 1What is PostgreSQL20 min
- 2psql and First Commands25 min
- 3Creating Databases and Tables30 min
- 4Data Types25 min
- 5SELECT and WHERE30 min
- 6Joins35 min
- 7Aggregates and Grouping30 min
- 8Indexes35 min
- 9Transactions and Isolation35 min
- 10Functions and Triggers35 min
- 11JSONB and Arrays35 min
- 12EXPLAIN and Query Tuning35 min
- 13Backup and Restore25 min
- 14Capstone: Design a Schema60 min
