postgresql自增id
drop index Ix_product_define_id; drop index Ix_user_umid; drop table invims_product_attention; /*==============================================================*/ /* Table: invims_product_attention */ /*==============================================================*/ create false table invims_product_attention ( product_attention_id SERIAL not null, user_umid VARCHAR(100) not null, product_define_id VARCHAR(64) not null, product_code VARCHAR(24) not null, date_created TIMESTAMP not null, date_updated TIMESTAMP not null, attention_status INT4 not null, constraint PK_INVIMS_PRODUCT_ATTENTION primary key (product_attention_id) ); comment on table invims_product_attention is '产品360_关注'; comment on column invims_product_attention.product_attention_id is '关注的id'; comment on column invims_product_attention.product_define_id is '产品的主键id'; comment on column invims_product_attention.product_code is '产品编码'; comment on column invims_product_attention.date_created is '创建时间'; comment on column invims_product_attention.date_updated is '更新时间'; comment on column invims_product_attention.attention_status is '关注状态:0 取消关注 1 已关注'; /*==============================================================*/ /* Index: Ix_user_umid */ /*==============================================================*/ create index Ix_user_umid on invims_product_attention ( user_umid ); /*==============================================================*/ /* Index: Ix_product_define_id */ /*==============================================================*/ create index Ix_product_define_id on invims_product_attention ( product_define_id );
SERIAL 相当于自增。
-- 创建sequence 序列,从1开始每次递增1,param_invims_product_attention_seq 是名称,不能重复 create sequence param_invims_product_attention_seq start with 1 incrementby 1 no minvalue no maxvalue cache; -- product_attention_id 为自增的列 alter tale public.invims_product_attention alter column product_attention_id set default nextval('param_invims_product_attention_seq')