How Oracle sets up auto-increment

Source: Internet
Author: User

1) Create a sequence:

1234567 createsequenceSEQ_TEST --字段名minvalue 1        --最小值maxvalue XXXXX      --设置最大值start with 1      --从1开始计数increment by1    --每次加1个nocycle           --一直累加,不循环nocache;          --不建缓冲区

2) sequence configuration in MyBatis:

Insert before MyBatis The new method you want to invoke

 

123 <selectKey resultType="java.lang.Long"order="BEFORE"keyProperty="id"    SELECT SEQ_TEST.Nextval as id from DUAL  </selectKey>

Note: The keyproperty here is the primary key attribute in Pojo, and it is important to note that there is no way to get the primary key ID already saved.

3) Also, attach the query sequence and delete the SQL

Inquire

1 selectfromuser_sequences;

Delete

1 DROPSEQUENCESEQ_TEST;

How Oracle sets up auto-increment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.