可以创建一个序列,它会自动递增rank列的值。
原文链接:https://www.f2er.com/postgresql/192901.htmlCREATE SEQUENCE rank_id_seq; CREATE TABLE yourtable ( rank INTEGER NOT NULL default nextval('rank_id_seq'),username VARCHAR(20) NOT NULL,password VARCHAR(50) NOT NULL ); ALTER SEQUENCE rank_id_seq owned by yourtable.rank;