Working with Complex Data Types

Learn to work with various complex data types such as arrays and JSON objects.

As we’ve seen, PostgreSQL allows us to store and manipulate traditional data types such as integers, strings, and booleans. But it also offers more complex data types for more specialized storage and manipulation.

One example is the array data type, which allows us to store an ordered list of elements within a single column. This can be useful for storing multiple choices in a single field, such as a list of hobbies or past job titles.

Array data type

We can declare a column to be of type array followed by the type of elements it will contain in square brackets. For example, we use the syntax hobbies TEXT[] to create a column for storing a list of text elements.

Get hands-on with 1200+ tech skills courses.