Sama seperti default lainnya, setelah Anda memperbaiki sintaks json:
CREATE TABLE mytable (
someothercol integer,
somecol json DEFAULT '{"name": "", "other_name": ""}'
);
Jika Anda menyetel ke DEFAULT
, hanya itu:
regress=> INSERT INTO mytable(someothercol, somecol) VALUES (42, '{"nondefault": 1}');
INSERT 0 1
regress=> SELECT * FROM mytable;
someothercol | somecol
--------------+-------------------
42 | {"nondefault": 1}
(1 row)
regress=> UPDATE mytable SET somecol = DEFAULT WHERE someothercol = 42;
UPDATE 1
regress=> SELECT * FROM mytable;
someothercol | somecol
--------------+--------------------------------
42 | {"name": "", "other_name": ""}
(1 row)