问题
I am using postgresql 9.4. I want to change existing primary key with serial. My query is not working. Anybody know how to do this?
Alter table 'table_name' alter column id BIGSERIAL;
There should be a single query to modify a particular column. I didn't see that
回答1:
CREATE SEQUENCE table_name_id_seq
OWNED BY table_name.id;
ALTER TABLE table_name
ALTER id
SET DEFAULT nextval('table_name_id_seq'::regclass);
来源:https://stackoverflow.com/questions/41847396/postgresql-9-4-make-existing-primary-key-as-serial