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) - 会有帮助吗? –