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
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.