From hstore to jsonb (type of column)
From hstore to jsonb (type of column)
От:
Alexandre Delanoë <debian@delanoe.org>
Дата:
Dear all,
from hstore to json, I use this:
ALTER TABLE ONLY mytable
ALTER COLUMN mycolumn
TYPE JSON
USING hstore_to_json(mycolumn)
;
ALTER TABLE ONLY mytable
ALTER COLUMN mycolumn
SET DEFAULT '{}'::json
;
But what would it become for jsonb ?
Replacing json by jsonb does not seem effective since there is no
hstore_to_jsonb fucntion apparently.
Many thanks for your help,
Best regards and many thanks for pgsql ecosystem.
--
Alexandre Delanoë
Re: From hstore to jsonb (type of column)
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alexandre =?iso-8859-1?Q?Delano=EB?= writes:
> from hstore to json, I use this:
> ALTER TABLE ONLY mytable
> ALTER COLUMN mycolumn
> TYPE JSON
> USING hstore_to_json(mycolumn)
> ;
> ALTER TABLE ONLY mytable
> ALTER COLUMN mycolumn
> SET DEFAULT '{}'::json
> ;
> But what would it become for jsonb ?
Just do "USING hstore_to_json(mycolumn)::jsonb". Eventually there
will probably be direct jsonb equivalents of all the existing
json transform functions, but they're not all there yet.
regards, tom lane
Re: From hstore to jsonb (type of column)
От:
Alexandre Delanoë <debian@delanoe.org>
Дата:
Le mardi 31 mars 2015, vers 10:02, Tom Lane écrivait: > Alexandre Delanoe writes: > > But what would it become for jsonb ? > > Just do "USING hstore_to_json(mycolumn)::jsonb". Eventually there > will probably be direct jsonb equivalents of all the existing > json transform functions, but they're not all there yet. Exactly what I was looking for. Besides it works like a charm. Many thanks for your quick help. Regards, -- Alexandre Delanoë