I'm trying to apply CYCLE to a BIGSERIAL in phpPgAdmin.

I've seen how to do it with a query, but I'd much rather be able to do it from phpPgAdmin.

Can this be done with phpPgAdmin? If so, how? If not, how can CYCLE be applied to a pre-existing BIGSERIAL column?

  • 1
    What's wrong with running a SQL statement? Any change to a production database should be done through script anyway (and they should be put into a version control system). Feb 10 '14 at 7:12
  • @a_horse_with_no_name Thank you for looking! Nothing at all, but I'm barely an amateur db guy, and this is for setup. The structure will be packaged into an app I'm writing. In my ignorance, it seems faster to be able to apply it via the GUI whenever I realize I need it. Besides, I can't find an example, lol. I hate noobs! ;))
    – user32234
    Feb 10 '14 at 7:15
  • 1
    @Gracchus since a while, I find it much faster to make changes to my DBs via the good old scripts. Actually, I don't use any GUIs anymore... Also, typing the commands always gives me the possibility to actually think about what I'm doing (or supposed to do) - I feel this a safer way than pressing buttons (without the possibility for rolling changes back).
    – dezso
    Feb 10 '14 at 9:29
  • @dezso Couldn't agree more. GUIes are for dumb dumbs, and my db level just isn't there yet. I hope to after my present project slows down. One day...
    – user32234
    Feb 10 '14 at 9:31

I don't use phpPgAmin.

To change an existing column definition to use the CYCLE attribute you need to understand that this is an attribute of the sequence not the "column".

A serial or bigserial is only a shorthand notation to assign a default value to a column which is take from a sequence.

When you define a column as serial Postgres automatically creates a sequences and applies the necessary default expression.

The sequence is usually called <table_name>_<column_name>_seq. But you can run a query to get the name of the generated sequence:

select pg_get_serial_sequence('your_table_name', 'your_column_name');

Once you know the name of the sequence, you can do the following:

alter sequence your_sequence_name cycle;

(Note that you need to commit that if you are not using auto-commit mode).

Here are some relevant links to the manual:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy