How to Add CYCLE to BIGSERIAL in phpPgAdmin

auto-incrementPHPpostgresql

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?

Best Answer

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: