PostgreSQL: insert from another table

后端 未结 4 974
悲&欢浪女
悲&欢浪女 2021-01-30 00:39

I\'m trying to insert data to a table from another table and the tables have only one column in common. The problem is, that the TABLE1 has columns that won\'t accept null value

4条回答
  •  抹茶落季
    2021-01-30 01:01

    Very late answer, but I think my answer is more straight forward for specific use cases where users want to simply insert (copy) data from table A into table B:

    INSERT INTO table_b (col1, col2, col3, col4, col5, col6)
    SELECT col1, 'str_val', int_val, col4, col5, col6
    FROM table_a
    

提交回复
热议问题