您的当前位置:首页 > 资讯 > postgresql
PostgreSQL字段自增
2018-08-09 18:00:06 来源:admin 点击:974
CREATE SEQUENCE river_beautiful_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
//如果没有创建则走下面的这个
CREATE TABLE "river_beautiful" (
"be_id" int8 DEFAULT nextval('river_beautiful_seq'::regclass) NOT NULL,
"be_title" varchar(255) COLLATE "default",
"be_image_url" varchar(255) COLLATE "default",
"be_video_url" varchar(255) COLLATE "default",
"be_updatetime" timestamp(6),
"be_createtime" timestamp(6),
"be_status" int2,
"be_sort" int8,
"be_desc" varchar(255) COLLATE "default",
);
//如果表创建了用上面的方法,
ALTER TABLE biaoming ALTER COLUMN id SET DEFAULT nextval('biaoming_id_seq')
如果在创建中用serial字段就是自增