Re: immediate set values - Mailing list pgsql-general

From Gregory Seidman
Subject Re: immediate set values
Date
Msg-id 20020519173413.A29305@jamaica.cs.brown.edu
Whole thread Raw
In response to Re: immediate set values  ("Joel Burton" <joel@joelburton.com>)
List pgsql-general
Joel Burton sez:
} Something like:
}
} INSERT INTO mytable SELECT 1, * FROM (select 1
}                                        union all
}                                       select 2
}                                        union all
}                                       select 3
}                                        union all
}                                       select 4)
}
} will work, but will run slowly, assuming you'll be inserting more than 4
} rows at a time.
}
} You could make a helper table that just contains integers <= n, if n is the
} max number of rows you want to insert.
}
} Then
}
} INSERT INTO mytable SELECT 1, i FROM ints WHERE i < 100;

Okay, I'm an idiot. The table I'm inserting into has two columns, each of
which references a key in another table. I already have the helper table I
need. Thanks for your help. My query now looks like:

INSERT INTO mytable
SELECT 1, id
FROM referencedtable
WHERE id IN (1,2,3,4)

} - J.
--Greg


pgsql-general by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: immediate set values
Next
From:
Date:
Subject: Re: Re : Solaris Performance - 64 bit puzzle