创建自增长序列(可以用SQL创建也可以用工具Navicat)
SQL创建序列(Sequences)(注意序列名用小写,不然会提示不存在)
CREATE SEQUENCE "public"."process_time_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 999999999
START 1
CACHE 1;
SELECT setval('"public"."process_time_seq"', 1, false);
ALTER SEQUENCE "public"."process_time_seq" OWNER TO "postgres";
Navicat创建序列(Sequences):
-- 查询序列:
SELECT nextval('process_time_seq');
--为主键设置Sequences:
alter table "public"."MACHINE_PROCESS_TIME" alter column "ID" set default nextval('process_time_seq');
--放入XML中
insert into "MACHINE_PROCESS_TIME" (
"ID",
"FACTORY_ID",
"WORKSHOP_ID",
"LINE_ID",
"STATION_ID",
"PROCESS_TIME",
"PROCESS_DATE",
"CREATE_DATE")values(
nextval('process_time_seq'),
#{factoryId,jdbcType=INTEGER},
#{workshopId,jdbcType=INTEGER},
#{lineId,jdbcType=INTEGER},
#{stationId,jdbcType=VARCHAR},
#{processTime,jdbcType=FLOAT},
#{processDate,jdbcType=DATE},
now())