PostgreSQL: insert from another table

PostgreSQL: insert from another table

Asked on January 9, 2019 in PostgreSQL.
Add Comment


  • 2 Answer(s)

    Simply provide  actual values in the SELECT:

    INSERT INTO TABLE1 (id, col_1, col_2, col_3)
    SELECT id, 'data1', 'data2', 'data3'
    FROM TABLE2
    WHERE col_a = 'something';
    

    A particular list can contain any value expression:

    Answered on January 9, 2019.
    Add Comment

    You can use this function

    insert into destination select coalesce(field1,'somedata'),... from source;
    
    
    Answered on January 9, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.