I am trying to add a json type column to the table, but it doesn’t work and I cannot get normal examples, what am I doing wrong?
ALTER TABLE user ADD COLUMN purshased_product SET DATA TYPE JSONB USING purshased_product::JSONB;
I'm not trying to change the column, but just create a new one with json type
@Convert(converter = PurshasedProductConverter.class)
private PurshasedProductConverter[] purshasedProducts;
my variable
To add a new column use:
ALTER TABLE "user" ADD COLUMN purshased_product jsonb;
Online example: https://rextester.com/SVST52826
The set data type
and using
clauses are only used to modify existing columns.
Note that user
is a reserved keyword. It's a bad idea to create a table with that name. If you insist on that, you have to use double quotes each time you refer to the table (as I did)