PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

PostgreSQL INSERT FROM SELECT com coluna adicional


Você pode especificar as colunas de destino entre parênteses antes de select cláusula:
INSERT INTO T1
(c1, c_additional) -- here
SELECT 
        C1,
        'needed_value' -- just select a constant here
FROM dblink(
    'hostaddr=127.0.0.1 port=5432 dbname=DB2 user=postgres password=postgres', 
    'SELECT * FROM T2')
AS T2_row(C1 integer)