I have created a table in PostgreSQL using this:
CREATE TEMP TABLE jsontesting
AS
SELECT id, jsondat
To add to Evan Carroll's answer, you may want to do the following to set the column to an empty array if it is NULL
. The append operator (||
) does nothing if the column is currently NULL
.
UPDATE jsontesting SET jsondata = (
CASE
WHEN jsondata IS NULL THEN '[]'::JSONB
ELSE jsondata
END
) || '["newString"]'::JSONB WHERE id = 7;