Feature request #14477
Add an option to create a sequence for existing integer columns
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | DB Manager | ||
Pull Request or Patch supplied: | No | Resolution: | |
Easy fix?: | No | Copied to github as #: | 22455 |
Description
Please add an option to create a sequence for existing integer columns in the DB Manager. Changing the type to serial in the 'Field properties' dialogue isn't working.
History
#1 Updated by Jürgen Fischer over 8 years ago
- Subject changed from DB Manager - Add an option to create a sequence for existing integer columns to Add an option to create a sequence for existing integer columns
#2 Updated by R. R. over 8 years ago
- File database_error.png added
- File edit_table_edit_column.png added
Wouldn't it be better to remove 'serial' and 'bigserial' until someone has implemented this feature?
#3 Updated by Jukka Rahkonen over 8 years ago
Can you do the same simply in PostgreSQL? I found this discussion https://www.postgresql.org/message-id/4505.1288879499%40sss.pgh.pa.us The conclusion by the developers was
We've looked at that in the past and decided there were enough corner
cases that it wasn't clearly a good idea. In particular, what do you do
with the existing data in the column? What do you do if there's already
a DEFAULT expression for the column, throw it away? In particular, what
of the special case that the column is in fact already a serial, so the
default is pointing at an existing sequence?
Making such a change to an existing table can be done manually
http://stackoverflow.com/questions/9490014/adding-serial-to-existing-column-in-postgres
It feels like users should really understand what they are going to do for their database and pgSQL is just the right tool.
There are many other impossible alternatives in the Edit column-Field properties-Type drop down menu and it would be hard to analyze which changes could be done and which ones not (if data hold in bigint can fit into smallint, if varchar is plain numbers without leading zeros and could be converted into integer etc.).
The title of this issue is "Add an option to create a sequence for existing integer columns".
I would close it as Won't fix because it is not a good idea.
About the suggestion "Wouldn't it be better to remove 'serial' and 'bigserial'" I am not sure. Perhaps it would be more better to let users try and throw an uniform error message "Type could not be changed from [a] into [b]" in case of failure and list possible additional messages from the database after that.
#4 Updated by Giovanni Manghi over 7 years ago
- Easy fix? set to No
#5 Updated by Jürgen Fischer almost 7 years ago
- Description updated (diff)