postgresql insert values from a select query

user19566

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.

Samir CHEKOR

There must be follow the step :

  1. drop the constraint PRIMARY KEY

    ALTER TABLE schema.cb DROP CONSTRAINT name_of_constraint;

  2. update the constrait not nul .

    ALTER TABLE schema.cb ALTER COLUMN id DROP NOT NULL;

  3. execute your insert.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Insert into … values ( SELECT … FROM … ) in postgresql?

From Dev

Insert values from select query into variables

From Dev

postgresql insert into from select

From Dev

Postgresql: INSERT INTO using SELECT and values

From Dev

PHP postgresql: INSERT values from query array result

From Java

Insert into ... values ( SELECT ... FROM ... )

From Dev

insert into table from query in Postgresql

From Dev

PostgreSQL; Using a SELECT sub-query in an INSERT

From Dev

PostgreSQL insert select multiple column values

From Dev

How to include the values of a select statement in an insert? (PostgreSQL)

From Dev

PostgreSQL: How to insert, select, and update values with underscores

From Dev

MYSQL INSERT INTO FROM SELECT QUERY

From Dev

How to insert a character inside the values of the select query

From Dev

Mysql Insert query with values and select as subquery

From Dev

Insert select query with custom values in node js

From Dev

sql query to create a table at runtime and insert the values in it from the select statement from the database

From Dev

PostgreSql INSERT FROM SELECT RETURNING ID

From Dev

Insert from Select Postgresql with primary key constraint

From Dev

PostgreSQL INSERT FROM SELECT with additional column

From Dev

INSERT INTO MySQL table SELECT FROM PostgreSQL table

From Dev

PostgreSQL INSERT FROM SELECT with additional column

From Dev

How to insert values from another table in PostgreSQL?

From Dev

PostgreSQL won't accept INSERT with VALUES and FROM?

From Dev

SQL Insert multiple Values where 1 value comes from a select query

From Dev

SQL Insert multiple Values where 1 value comes from a select query

From Dev

Insert Average into table from select query

From Dev

Regex to extract values from Insert Query

From Dev

Query for Insert into using values from other table

From Dev

Insert VALUES from query multi row

Related Related

  1. 1

    Insert into … values ( SELECT … FROM … ) in postgresql?

  2. 2

    Insert values from select query into variables

  3. 3

    postgresql insert into from select

  4. 4

    Postgresql: INSERT INTO using SELECT and values

  5. 5

    PHP postgresql: INSERT values from query array result

  6. 6

    Insert into ... values ( SELECT ... FROM ... )

  7. 7

    insert into table from query in Postgresql

  8. 8

    PostgreSQL; Using a SELECT sub-query in an INSERT

  9. 9

    PostgreSQL insert select multiple column values

  10. 10

    How to include the values of a select statement in an insert? (PostgreSQL)

  11. 11

    PostgreSQL: How to insert, select, and update values with underscores

  12. 12

    MYSQL INSERT INTO FROM SELECT QUERY

  13. 13

    How to insert a character inside the values of the select query

  14. 14

    Mysql Insert query with values and select as subquery

  15. 15

    Insert select query with custom values in node js

  16. 16

    sql query to create a table at runtime and insert the values in it from the select statement from the database

  17. 17

    PostgreSql INSERT FROM SELECT RETURNING ID

  18. 18

    Insert from Select Postgresql with primary key constraint

  19. 19

    PostgreSQL INSERT FROM SELECT with additional column

  20. 20

    INSERT INTO MySQL table SELECT FROM PostgreSQL table

  21. 21

    PostgreSQL INSERT FROM SELECT with additional column

  22. 22

    How to insert values from another table in PostgreSQL?

  23. 23

    PostgreSQL won't accept INSERT with VALUES and FROM?

  24. 24

    SQL Insert multiple Values where 1 value comes from a select query

  25. 25

    SQL Insert multiple Values where 1 value comes from a select query

  26. 26

    Insert Average into table from select query

  27. 27

    Regex to extract values from Insert Query

  28. 28

    Query for Insert into using values from other table

  29. 29

    Insert VALUES from query multi row

HotTag

Archive