I'm new to the SQL and I have a problem with setting default value for a column using this command. The thing is I have to get product's brutto price.
ALTER TABLE produkt
ADD vat DECIMAL(5,2) DEFAULT 0.23;
ALTER TABLE produkt
ADD price_br INTEGER DEFAULT var*PRICE_NET;
"produkt" is my Table PRICE_NET is netto price of a product.
After trying to add price_br column I'm getting "column not allowed here" error. I assume It's quite an easy task, but i can't really figure it out.
I think you want a computed column, not a default value. That would be:
ALTER TABLE produkt ADD price_br INTEGER GENERATED ALWAYS AS (var*PRICE_NET);