Thread: RE: [SQL] Simple Question??

RE: [SQL] Simple Question??

From
Michael Davis
Date:
I would say yes as long as table_b still references the same sequence as
table_a.  Sequences are stored and maintained separately from the tables
they are used in.  If you drop and recreate a sequence, the starting number
of that sequence will be 1 even though the database using the sequence has
500 records in it.  You can reset the value of the sequence (seq_a) to the
highest value currently stored in the database for the column that seq_a is
being used with.  When I ported my Access97 table to Postgres, I had to set
the value of each sequence I used to match the highest value stored in my
tables.

    -----Original Message-----
    From:    archiver [SMTP:archiver@db.geocrawler.com]
    Sent:    Saturday, February 27, 1999 3:51 PM
    To:    pgsql-sql@hub.org
    Subject:    [SQL] Simple Question??

    Here's a question that maybe you can answer easily...

    If I am using a sequence (seq_a) in table_a

    ...then "create table_b as select * from table_a"

    ...does table_b start using that sequence (seq_a), starting at the
point
    where table_a left off??

    I have a 1GB table that I want to optimize by reordering it, and I
will want
    the new table to use the same sequence to generate the primary key.
I will
    then drop the original table and rename the table_b to table_a.

    Any clues?

    Tim Perdue
    tim@perdue.net