Re: Learning Plpgsql ??

From: Jason Earl <jason(dot)earl(at)simplot(dot)com>
To: Jim Beckstrom <jrbeckstrom(at)sbcglobal(dot)net>
Cc: jonathon(at)octahedron(dot)com(dot)au, pgsql-novice(at)postgresql(dot)org
Subject: Re: Learning Plpgsql ??
Date: 2003-01-24 17:29:47
Message-ID: 87wukucv78.fsf@npa01zz001.simplot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jim Beckstrom <jrbeckstrom(at)sbcglobal(dot)net> writes:

> Coming from another newbie, here's what I use to set the sequence
> following an import of text data. I create seqence and table and
> import one file at a time, for a one time conversion, so I don't need
> the table of table names,etc., but that's a great idea, like a data
> dictionary concept. Would this work, modified to fit your loop syntax?
>
> select SETVAL('link_rep_link_rep_id_seq', (select max(link_rep_id)
> from link_rep))
>
> Jim

For really large tables

SELECT SETVAL('link_rep_link_rep_id_seq', (SELECT link_rep_id
FROM link_rep ORDER BY link_rep_id DESC LIMIT 1))

will be quite a bit faster (you'll save yourself a tablescan).

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jason Earl 2003-01-24 17:30:58 Re: Starting postgresql server in RedHat 8.0
Previous Message Jason Earl 2003-01-24 17:25:25 Re: Initial user and RedHat 8.0