oracle新建序列自增主键,查询序列当前最大值

阅读 121

2023-01-12

因为oracle设计表的时候不像mysql可以设置自增主键,所以只能通过建序列方式。

建序列

create sequence SEQ_DP_CUST_COUPON increment by 1 minvalue 1 maxvalue 9999999999999999999999999999 start with 2 cache 20;

查询下一个序列值

select seq_coupons_tx_2_id.nextval from dual;

想要在程序里插入一条数据(SEQ_DP_CUST_COUPON是序列名字,nextval代表下一个值)

insert into dp_cust_coupon (COUPON_ID,CUST_NO,COUPON_PSD) values (SEQ_DP_CUST_COUPON.nextval,:custNo,:couponPsd)

唤醒存储过程

try {String callElseProcedure = "{call coupon_batch_import()}";
oracleZsNpJdbcTemplate.getJdbcOperations().execute(callElseProcedure);} catch(Exception e) { e.printStackTrace(); }

精彩评论(0)

0 0 举报