The ID of an Oracle table is automatically added when the Oracle table is created.

Source: Internet
Author: User

 

Exec pro_create ('lt _ oa_sms ', 'smsid '); First, perform the first step:

Create sequence auto_add -- sequence name (auto_add is a series name, just name it)
Increment by 1 -- increase by 1 each time
Start with 1 -- start from 1
Nomaxvalue -- no maximum value
Nocache -- no cache Sequence

 

Next, perform Step 2:

Create or replace trigger trg_lt_commenduser/* ---- (myproject) trigger name ----*/
Before insert on lt_commenduser/* ---- (project_manage) Table Name ----*/
For each row
Begin
If (: New. commendid is null) Then/* ---- (productionid) column name ----*/
Select auto_add.nextval into: New. commendid from dual;/* ---- (auto_add) sequence name ---- * // * ---- (productionid) column name ----*/
End if;
End;

This is the auto-increment method of Oracle keys.

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.