I would like to change the name of my sequence I use. I tried those two options and failed:
ALTER TABLE PLAYER RENAME id_seq_player TO player_id_seq;
and
ALTER SEQUENCE id_seq_player RENAME TO player_id_seq;
I looked at the official documentation and from there I created those two SQL, but none of them worked. The first solution resulted in a SQL error and the second had a time out.
Here is the SQL error I get:
ERROR: column "id_seq_player" does not exist ********** Error **********
* UPDATE *
Seems like the second SQL statement did the job. Since I have to forward the port, maybe it was an issue with the connection or OpenShift. But now I retried several times to verify and it works.
ALTER SEQUENCE id_seq_player RENAME TO player_id_seq; /* Works */
ALTER SEQUENCE old_id_seq RENAME TO new_id_seq; ALTER TABLE mytable ALTER COLUMN id SET DEFAULT nextval('new_id_seq');
Sequences objects are created by using the CREATE SEQUENCE statement. Sequences are integer values and can be of any data type that returns an integer. The data type cannot be changed by using the ALTER SEQUENCE statement. To change the data type, drop and create the sequence object.
"Alter column position" in the PostgreSQL Wiki says: PostgreSQL currently defines column order based on the attnum column of the pg_attribute table. The only way to change column order is either by recreating the table, or by adding columns and rotating data until you reach the desired layout.
ALTER SEQUENCE id_seq_player RENAME TO player_id_seq;
is correct. You might want to add the schema name as well to ensure you are altering the correct one, but this should most likely work.
If it timeouts, you might have another process that is locking your sequence. Is there a way for you to turn off all the other database users, or is it too critical to do so?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With