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')
postgresql自增id的更多相关文章
- mybatis postgresql insert后返回自增id
在使用mybatis + postgresql,我们有时在插入数据时需要返回自增id的值,此时在插入时,可以按照以下例子来编写mapper文件 <insert id="insertUs ...
- 【MyBtis】获取数据插入postgresql后返回的自增id
问题描述 数据库采用的是postgresql,以下面的rule表为例,该表的id设置为自增,那么经常有这样的需求,在执行insert操作后,紧接着需要获取该记录的自增id往中间表中插入数据,或者是再根 ...
- postgreSQL 自增需要使用序列
postgreSQL 自增需要使用序列 1.使用SERIAL CREATE TABLE users ( id SERIAL4 primary key , name character varying, ...
- MySQL自增ID 起始值 修改方法
在mysql中很多朋友都认为字段为AUTO_INCREMENT类型自增ID值是无法修改,其实这样理解是错误的,下面介绍mysql自增ID的起始值修改与设置方法. 通常的设置自增字段的方法: 创建表格时 ...
- sqlserver 自增ID插入指定数据
set identity_insert 表名 ON --允许对自增列Id插入指定数据 insert into table_name(Id,Name) values(1,'test') set iden ...
- MYSQL获取自增ID的四种方法
MYSQL获取自增ID的四种方法 1. select max(id) from tablename 2.SELECT LAST_INSERT_ID() 函数 LAST_INSERT_ID 是与tabl ...
- Twitter-Snowflake,64位自增ID算法详解
Twitter-Snowflake算法产生的背景相当简单,为了满足Twitter每秒上万条消息的请求,每条消息都必须分配一条唯一的id,这些id还需要一些大致的顺序(方便客户端排序),并且在分布式系统 ...
- mysql插入数据后返回自增ID的方法
mysql和oracle插入的时候有一个很大的区别是,oracle支持序列做id,mysql本身有一个列可以做自增长字段,mysql在插入一条数据后,如何能获得到这个自增id的值呢? 方法一是使用la ...
- 事务回滚后,自增ID仍然增加
回滚后,自增ID仍然增加. 比如当前ID是7,插入一条数据后,又回滚了.然后你再插入一条数据,此时插入成功,这时候你的ID不是8,而是9.因为虽然你之前插入回滚,但是ID还是自增了. 如果你认为自增I ...
随机推荐
- 4.27-Postman和JMeter总结及实战描述
一.数据格式 常用的请求方法有8种,但是最常用的有4-5种 1.GET 获取资源 2.POST 添加资源(对服务端已存在的资源也可以做修改和删除操作) 3.PUT 修改资源 4 .DELETE删除资源 ...
- 自己在ubuntu16.04 上用的软件和配置
软件: 1.WPS2019: 这个不用多说了,真的是比之前的wps好太多了. 2.Chrom的画图插件: http://Draw.io,非常强,Draw.io 是一款在线图表编辑工具, 可以用来编辑工 ...
- VMware16搭建Ubuntu22.04,更新为国内下载源,安装open-vm-tools,用SecureCRT远程连接
前期准备 1.VMware16(转载:下载安装流程:(https://www.bilibili.com/read/cv9694457)) 2.Ubuntu22.04----iso镜像文件(下载地址:( ...
- Apache Kafka 集群部署指南
公众号关注 「开源Linux」 回复「学习」,有我为您特别筛选的学习资料~ Kafka基础 消息系统的作用 应该大部分小伙伴都清楚,用机油装箱举个例子. 所以消息系统就是如上图我们所说的仓库,能在中间 ...
- 基于 range 的 for 循环和 auto
基于 range 的 for 循环和 auto C++11 引入一种循环的新形式,叫基于 range 的 for 循环,它允许我们用更简单易读的形式遍历容器中的所有元素 vector<int&g ...
- 太极限了,JDK的这个BUG都能被我踩到
hello,大家好呀,我是小楼. 之前遇到个文件监听变更的问题,刚好这周末有空研究了一番,整理出来分享给大家. 从一次故障说起 我们还是从故障说起,这样更加贴近实际,也能让大家更快速理解背景. 有一个 ...
- Resource wordnet not found. Please use the NLTK Downloader to obtain the resource:
第一次使用nltk的时候,出现了这样的错误: from nltk.stem.wordnet import WordNetLemmatizer lemmatizer = WordNetLemmatize ...
- uniapp复制到剪贴板
uni.setClipboardData() ; 例: 给元素添加点击事件 <view @click="doCopy()">复制</view> 复制方法 d ...
- for循环+数字类型补充
一.for循环 1.循环取值 1.1列表类型: 定义l=['a','b','c'],要提取列表中的值 如果采用while循环的话: print(len(l)) i=0 while i& ...
- 虚拟机:KVM
1. KVM 介绍 1.0 虚拟化简史 其中,KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是Linux 的一个内核模块,该内核模块使得 Linux ...