Temporary tables are stored in RAM until the available memory is used up, at which time they spill onto disk. The relevant setting here is
temp_buffers
.Either way, they live for the duration of a session and are dropped at the end automatically.
You can also drop them at the end of a transaction automatically (
ON COMMIT DROP
) or manually any time.Temporary table are only visible to the the same user in the same session. Others cannot access it - and also not conflict with it.
Always use
CREATE TABLE tbl AS ...
. The alternative formSELECT ... INTO tbl
is discouraged since it conflicts with theINTO
clause in plpgsql.
Your query could look like:
CREATE TEMP TABLE tbl AS
SELECT a.run_uid, s.object_uid
FROM dt.table_run_group a
JOIN dt.table_segment s ON a.group_uid = s.object_uid;