highgo=#createsequencet_seqincrementby1startwith1; CREATESEQUENCE highgo=#selectnextval('t_seq');--查看序列中下一个值 nextval --------- 1 (1行记录)
highgo=#createtablet(idintdefaultnextval(‘t_seq’),namevarchar);--在定义时使用sequence CREATETABLE highgo=#insertintot(name)values('jasmine'),('lily'); INSERT02 highgo=#select*fromt; id|name ----+--------- 2|jasmine 3|lily (2行记录)
highgo=#createtablet1(idint,namevarchar); CREATETABLE highgo=#selectnextval('t_seq'); nextval --------- 6 (1行记录) highgo=#insertintot1values(nextval('t_seq'),'jim');--在插入int数值时使用sequence INSERT01 highgo=#select*fromt1; id|name ----+------ 7|jim (1行记录)