Re: immediate set values

From: Gregory Seidman <gss+pg(at)cs(dot)brown(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: immediate set values
Date: 2002-05-19 21:34:13
Message-ID: 20020519173413.A29305@jamaica.cs.brown.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message markir 2002-05-20 02:46:18 Re: Re : Solaris Performance - 64 bit puzzle
Previous Message Joel Burton 2002-05-19 21:23:10 Re: immediate set values