0
如何以串行方式更改表列。這列已經在數據單項它,我不想失去他們.. 我已經試過這樣:將列的數據類型更改爲串行postgresql
ALTER TABLE tbl_user ADD COLUMN usr_id SERIAL PRIMARY KEY;
我得到這個錯誤
ERROR: column "usr_id" of relation "tbl_user" already exists ********** Erreur **********
我想這也:
UPDATE tbl_user SET usr_id = nextval('seq_user') WHERE usr_id IS NULL;
Query returned successfully: 0 rows affected, 71 msec execution time.
查詢轉succesfull但不改變列類型
另請參見[將'serial'添加到Postgres中的現有列](http://stackoverflow.com/questions/9490014/adding-serial-to-existing-column-in-postgres)和[更多](http: //stackoverflow.com/search?q=%5Bpostgresql%5D+alter+serial)... – pozs
感謝您的幫助 – Kamfasage
一個非常相似的問題在[http://stackoverflow.com/ques tions/12591207 /如何將整數轉換爲序列](http://stackoverflow.com/questions/12591207/how-to-convert-integer-to-serial) - 會有幫助嗎? –