I am trying to insert values from a select query using this:
INSERT INTO cb (vol_sec)
SELECT sum(vol)
FROM cb
GROUP BY cusec;
but the error message is ERROR: the value null for column «id» restriction violates not null. I have tried to change NOT NULL to NULL but i have another message 'The column <> is in the primary key. Is there any way to avoid this errors?.Thanks in advance.
There must be follow the step :
drop the constraint PRIMARY KEY
ALTER TABLE schema.cb DROP CONSTRAINT name_of_constraint;
update the constrait not nul .
ALTER TABLE schema.cb ALTER COLUMN id DROP NOT NULL;
execute your insert.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments