Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Location
    Philippines
    Posts
    10

    Talking Unanswered: how to reset value of a sequence?

    Good day!

    How do I reset the value of a sequence without dropping the table?

    Could you help me out?

  2. #2
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    sequence

    you can do this by updateing one of the system tables

    It's a long time ago since I've done this.

    I will look it up and post it.

    But this is a very dangerous procedure to reset the sequence.

    I've forgotten the easy method to reset the sequence is to pg_dumpall of your database
    and then search fpr the sequence in the ascii file and you can change the setting also there
    and then import your data in den dbserver and theen the sequence is changed

    with this method you can change the sequence to any value you want.

    BUT NOTICE THIS DANGERAOUS DEALING WITH SUCH THINGS ON A PRODUCTION SYSTEM.
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  3. #3
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    sequence

    use \d [sequence]

    and use setval to change the value of the sequence
    Last edited by eperich; 02-09-02 at 05:42.
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  4. #4
    Join Date
    Jan 2002
    Posts
    19

    Re: how to reset value of a sequence?

    Originally posted by zdeh98
    Good day!

    How do I reset the value of a sequence without dropping the table?

    Could you help me out?
    Is enough:

    DROP SEQUENCE sequence_name;

    and after the first increment will be recreated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •