select setval('table_id_seq',select max(id) from table); 例如 select setval('user_id_seq',select max(id) from user);