Create a growth generator in oracle Region

Source: Internet
Author: User
SQL generation

-- 1. Create a table in tables
Create table tb_users
(
Id number (4 ),
UserName varchar2 (20 ),
Password varchar2 (20)
)
-- 2. Sequence Creation
Create sequence sq_user
Start with 1
Increment by 1
-- 3. producer
Create or replace trigger tri_tb_users
Before insert on tb_users
For each row
Begin
Select sq_user.nextval into: new. id from dual;
End;
-- 4. Add a data volume
Begin
Insert into tb_users (username, password) values ('xiachufeng', 'xiachufeng ');
Insert into tb_users (username, password) values ('kevin ', 'kevin ');
Commit;
End;
-- 5. Check the incremental data and find that the id column is incremented.
Select * from tb_users

 

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.