[Reverse migration] Create a table in Oracle, create a sequence, create an auto-incrementing field, add a comment, add a record, add a trigger, and submit

Source: Internet
Author: User

Most people are used to the operations of other databases. One field is an auto-incrementing sequence field, but Oracle-related help is queried.

View the relatedArticle, Repost this article to share with you

 

// Create a sequence
Create sequence car_guid increment by 1;

// Create a table
Create Table car
(
Guid number not null primary key,
Phoneid char (11) not null,
Username varchar (20) not null
);

// Add comments
Comment on table car is 'positioning information user table ';
Comment on column car. GUID is 'auto-incrementing field ';
Comment on column car. phoneid is 'unique telephone identification ';
Comment on column car. username is 'user name ';

// Add a record
Insert into car (guid, phoneid, username) values (car_guid.nextval, '000000', 'zhangsan ');

// Submit
Commit;

// Trigger
Create or replace trigger trigger_car_guid_insert
Before insert on car
For each row
Begin
Select carguidseq. nextval into: New. guid from SYS. Dual;
End;

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.