Oracle SQL Create tables Oracle build table Set PRIMARY key auto-increment

Source: Internet
Author: User

1. Create a new table

CREATE TABLEYsb_log (ID Number(8)Primary Key  not  NULL, Tbdatevarchar( -)NULL, Tb_timevarchar( -) not NULL, Tblogvarchar( -) not NULL, Tbreorvarchar2( -)NULL, BSvarchar( -) not NULL  );

In Oracle, sequence is the so-called serial number, which is automatically incremented each time it is taken, and is typically used where serial numbers need to be sorted.

2. Create a self-increment

Create1    99999999--the largest paper with 1       by 1   -- keep accumulating, not looping -- do not build buffers

Select S_ysb_log. Currval from dual---to search for the current primary key value,
Select S_ysb_log. Nextval from dual--query the next value

3. Insert data into the table:

Insert  into   ysb_log (ID, tbdate, tb_time, Tblog, Tbreor, BS)values'2016-7-21', ' 10:01:00 ','dddd',null'orderdown'  )

places where you can use sequence:
-SELECT statements that do not contain subqueries, snapshot, and view
-INSERT statement in subqueries
-In the values of the Nsert statement
-In the set of UPDATE

Oracle SQL CREATE TABLE Oracle build tables Set PRIMARY key auto-increment

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.