重置自增id
// 1.查询表主键序列 - public.table_id_seqSELECTpg_get_serial_sequence('table','id');// 2.查询table最大id - 4399selectmax(id)from table;// 3.将自增序列数设置到最大值,下次新增就会从4400开始SELECTsetval('public.table_id_seq',4399);移除主键与新增主键
// 移除主键:// 1.查询当前表主键 - table_pkeySELECT constraint_name FROM information_schema.table_constraintsWHEREtable_name='table'ANDconstraint_type='PRIMARY KEY';// 2.移除主键ALTER TABLE table DROPCONSTRAINTtable_pkey;// 新增主键ALTER TABLE table ADDPRIMARYKEY(id);