Steve Midgley <[EMAIL PROTECTED]> writes:
> The code I provided to reset a primary key sequence is actually part of
> Ruby on Rails core library - actually they use something very similar
> to what I originally sent:
> SELECT setval('#{sequence}', (SELECT COALESCE(MAX(#{pk})+(SELECT
> increment
Hi Scott,
You've moved into more general territory, so I'm starting a new thread.
The code I provided to reset a primary key sequence is actually part of
Ruby on Rails core library - actually they use something very similar
to what I originally sent:
SELECT setval('#{sequence}', (SELECT COAL
On Aug 3, 2007, at 15:27 , Erik Jones wrote:
Is there actually a requirement that the block of 5000 values not
have gaps?
Good point.
If not, why not make the versioned table's id column default to
nextval from the same sequence?
Of course, the ids of the two tables could be interleaved
On Aug 3, 2007, at 14:28 , Steve Midgley wrote:
AIUI, one difference between the solutions Scott and I proposed is
that while INCREMENT is set at 5000, each time nextval is called the
sequence is incremented by 5000. For example:
test=# select nextval('foos_foo_id_seq');
nextval
-
On Aug 3, 2007, at 11:50 AM, Steve Midgley wrote:
Hi,
I'm writing an import app in a third party language. It's going to
use "copy to" to move data from STDIN to a postgres (8.2) table.
There are some complexities though: it's going to copy the records
to a "versioned" table first, and th
On Aug 3, 2007, at 2:24 AM, Dani Castaños wrote:
Josh Tolley escribió:
On 8/2/07, Dani Castaños <[EMAIL PROTECTED]> wrote:
Hi all!
Is it possible to have a foreign key where referenced table is in
another database?
Thank you in advance
---(end of
broadcast)--
Oh, another point. You should run the
alter sequence m increment 5000;
select nextval('m');
alter sequence m increment 1;
one right after the other to reduce the number of 5000 wide holes in
your sequence.
Or, given the size of bigint, you could just set the increment to 5000
and leave it there
On 8/3/07, Steve Midgley <[EMAIL PROTECTED]> wrote:
> Hi Scott,
>
> Thanks for this info (and Michael too!).
>
> Let me see if I understand your suggestion. I would run these three
> commands in sequence:
>
> # select nextval('[my_seq_name]');
> returns => 52 [I believe that the sequence is at 52]
Hi Scott,
Thanks for this info (and Michael too!).
Let me see if I understand your suggestion. I would run these three
commands in sequence:
# select nextval('[my_seq_name]');
returns => 52 [I believe that the sequence is at 52]
# alter sequence [my_seq_name] increment by 5000;
# select nextv
On 8/3/07, Steve Midgley <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm writing an import app in a third party language. It's going to use
> "copy to" to move data from STDIN to a postgres (8.2) table. There are some
> complexities though: it's going to copy the records to a "versioned" table
> first
On Aug 3, 2007, at 11:50 , Steve Midgley wrote:
My problem: I'd like to be able to grab a block of id's from the
live table's pk sequence. So let's say my importer has 5,000 new
rows to import and the current max pk in the live table is 540,203.
I'd like to be able to increment the primary
Hi,
I'm writing an import app in a third party language. It's going to use
"copy to" to move data from STDIN to a postgres (8.2) table. There are
some complexities though: it's going to copy the records to a
"versioned" table first, and then at a later time the records will be
copied by a dif
Josh Tolley escribió:
On 8/2/07, Dani Castaños <[EMAIL PROTECTED]> wrote:
Hi all!
Is it possible to have a foreign key where referenced table is in
another database?
Thank you in advance
---(end of broadcast)---
TIP 1: if posting/reading thro
do this via execute in a stored procedure - something like this (written on the
flow - untested!)
returns setof text
declare
my_record record;
my counter as bigint;
begin
for my_record in
select tablename from pg_tables where
schemaname = 'public'
loop
execute into counter
14 matches
Mail list logo