0

I have two tables: the first table, customer_campaign_import, has 7 columns. The second table, customer_campaign, has more columns than the first table with id(uuid type) as the primary key. Since id is the type not-null constant , when I execute the following query:

INSERT INTO customer_campaign (store_name, store_address, store_city, store_province,     
 store_postal_code, lat, long)
SELECT * FROM customer_campaign_import;

It returns an error:

ERROR:  null value in column "id" violates not-null constraint

How do I generate a unique id for each row of the first table when inserting the first table into the second table?

Sai Wai Maung
  • 1,607
  • 6
  • 18
  • 28
  • 1
    Set your id to auto-increment with serial. For more read [here][1]. [1]: http://stackoverflow.com/questions/9490014/adding-serial-to-existing-column-in-postgres – Carlo Oct 02 '14 at 19:41

1 Answers1

1

ALTER the type of id to serial solved the problem.

Sai Wai Maung
  • 1,607
  • 6
  • 18
  • 28