Auto-increment of oracle trigger + sequence id

Source: Internet
Author: User


1. select * from s_hrdata
2. create Sequence: create sequence s_hrdata_SEQUENCE start with 1 increment by 1
3. CREATE Trigger: create or replace trigger s_hrdata_trgger before insert or update of id on s_hrdata for each row begin select s_hrdata_SEQUENCE.NEXTVAL INTO: NEW. id from dual; END; no id is required when inserting data. Insert into s_hrdata (c_xm, c_xb, c_sfzh, c_ygbh, c_qdbm, c_ssjg, c_sgid, c_zwgw, c_zzzt, c_rzsj, c_tbsj, struct) values ('liangjm ', 'M ', '123', 'ab005618', 'df ', 'sddd', 'cc', 'dd', 1, sysdate, sysdate, 'ter '); select * from s_hrdata author ljm1227134894

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.