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')

postgresql自增id的更多相关文章

  1. mybatis postgresql insert后返回自增id

    在使用mybatis + postgresql,我们有时在插入数据时需要返回自增id的值,此时在插入时,可以按照以下例子来编写mapper文件 <insert id="insertUs ...

  2. 【MyBtis】获取数据插入postgresql后返回的自增id

    问题描述 数据库采用的是postgresql,以下面的rule表为例,该表的id设置为自增,那么经常有这样的需求,在执行insert操作后,紧接着需要获取该记录的自增id往中间表中插入数据,或者是再根 ...

  3. postgreSQL 自增需要使用序列

    postgreSQL 自增需要使用序列 1.使用SERIAL CREATE TABLE users ( id SERIAL4 primary key , name character varying, ...

  4. MySQL自增ID 起始值 修改方法

    在mysql中很多朋友都认为字段为AUTO_INCREMENT类型自增ID值是无法修改,其实这样理解是错误的,下面介绍mysql自增ID的起始值修改与设置方法. 通常的设置自增字段的方法: 创建表格时 ...

  5. sqlserver 自增ID插入指定数据

    set identity_insert 表名 ON --允许对自增列Id插入指定数据 insert into table_name(Id,Name) values(1,'test') set iden ...

  6. MYSQL获取自增ID的四种方法

    MYSQL获取自增ID的四种方法 1. select max(id) from tablename 2.SELECT LAST_INSERT_ID() 函数 LAST_INSERT_ID 是与tabl ...

  7. Twitter-Snowflake,64位自增ID算法详解

    Twitter-Snowflake算法产生的背景相当简单,为了满足Twitter每秒上万条消息的请求,每条消息都必须分配一条唯一的id,这些id还需要一些大致的顺序(方便客户端排序),并且在分布式系统 ...

  8. mysql插入数据后返回自增ID的方法

    mysql和oracle插入的时候有一个很大的区别是,oracle支持序列做id,mysql本身有一个列可以做自增长字段,mysql在插入一条数据后,如何能获得到这个自增id的值呢? 方法一是使用la ...

  9. 事务回滚后,自增ID仍然增加

    回滚后,自增ID仍然增加. 比如当前ID是7,插入一条数据后,又回滚了.然后你再插入一条数据,此时插入成功,这时候你的ID不是8,而是9.因为虽然你之前插入回滚,但是ID还是自增了. 如果你认为自增I ...

随机推荐

  1. 攻防世界-MISC:神奇的Modbus

    这是攻防世界高手进阶区的第三题,题目如下: 点击下载附件一,得到一个流量包,题目中提到的modbus,百度百科的解释如下: 用wireshark打开流量包,搜索modbus 然后鼠标右键选择追踪流,再 ...

  2. Bootstrap Blazor 模板使用(一)Layout 组件

    原文链接:https://www.cnblogs.com/ysmc/p/16197223.html BootstrapBlazor 官网地址:https://www.blazor.zone Boots ...

  3. WFP资源

    资源基础 WPF程序在代码中以及在标记中的各个位置定义资源,具有高效性.可维护性.适应性的优点. 资源的层次 <Windows.Resource> <ImageBrush x:key ...

  4. 微信小程序绑定函数如何携带参数

    一开始以为微信小程序的语法是和VUE的语法一样的,直接@click="click(field)",结果却不是这样的 在微信小程序中我们需要设置一个 data-set ,然后在绑定的 ...

  5. Mybatis Plus之内置Mapper实践

    MyBatis Plus,作为对MyBatis的进一步增强,大大简化了我们的开发流程,提高了开发速度 配置 由于Mybatis Plus是建立在Mybatis之上的,所以其已经依赖了Mybatis,故 ...

  6. unity---对象池

    当内存占满了,GC会自动清理内存 优化方法:对象池 Invoke("Push",1);//延迟一秒时间调用 高级缓存池 小池子 大池子

  7. spring boot 在控制台打印banner

    转自 SpringBoot系列--花里胡哨的banner.txt - huanzi-qch - 博客园 (cnblogs.com) <div id="cnblogs_post_body ...

  8. 在 4GB 物理内存的机器上,申请 8G 内存会怎么样?

    作者:小林coding 计算机八股文刷题网站:https://xiaolincoding.com/ 大家好,我是小林. 看到读者在群里讨论这些面试题: 其中,第一个问题「在 4GB 物理内存的机器上, ...

  9. android系统常见问题类型

    android系统中常见的异常问题,包括上层应用.框架.内核.驱动等,一般来说有如下一些异常问题类型: ANR,Answer No Response,应用无响应. FC,Force Close,强制退 ...

  10. 2021.06.12【NOIP提高B组】模拟 总结

    T1 题目大意:有 \(n\) 个点,到点 \(i\) 可以获得 \(A_i\) ,同时消耗 \(B_i\) 若当前价值小于 \(B_i\) 则不能到,问从 \(P\) 开始,任一点结束后的最大值. ...