Oracle creates a primary key from growth ____oracle

Source: Internet
Author: User

Create a sequence first

CreateSequence testincrease_sequence
IncrementBy 1--each time you add
a few startwith 1--start counting from 1
nomaxvalue--do not set the maximum value, To set the maximum value: maxvalue9999
nocycle--has been accumulated, does not cycle
Note that the pl/sql is created in the trigger, and can not immediately get the sq sequence, need to exit again to re-enter on it, the truth of which I am not very clear

And then create the trigger

Create or replace trigger MER_ONECODEPAYMENT_TRG
  before insert on
  merchant_onecodepayment_info for each 
  Row
declare
  --local variables here
begin
  Select Mer_onecodepayment_seq.nextval into:New.id from Dual;
End MER_ONECODEPAYMENT_TRG;


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.