In the MySQL database, you want to implement a self-increment function of the data (that is, when inserting this data, fill in null, System automatic + 1), you can use the statement auto-increment directly in the column.
int Primary Key Auto_increment
This is not used in Oracle databases. The following describes how to implement the self-increment of the ID column in an Oracle database.
1 Create a table cutomers. (Needless to say)
1 Create TableCustomers (2Id Number(Ten), 3Namevarchar( -) not NULL,4Addressvarchar( -),5Phonevarchar( -),6 constraintCustomers_id_pkPrimary Key(ID),7 constraintCustomers_name_ukUnique(name)8 9)
2 Create a sequence sequence.
1 CREATE SEQUENCE customers_sequence 2 by 1---Add 1 each time 3 with 1-----Starting from 1 4 nomaxvalue-------Not set the maximum value 5 nocycle----------always accumulate, do not cycle
3 Create a trigger so that each time the data is inserted it touches the trigger to automatically add 1 to the process.
1 CREATE TRIGGER Customersid_increase 2 before 3 INSERT on for Each ROW 4 begin 5 Select into from dual; 6 End;
4 Validation: When inserting data, the ID column can be directly written as null.
1 insert into customers values (null , tom ", " miami , " 18376326890 )
2 Insert into Values (null,'Wade','Chicago',' 13157632690')
To view the data in a table, you can:
1 Tom Miami 18376326890 ...............
2 Wade Chicago ...... ..... ........................
The ID column implements the Automatic plus 1 feature.
Auto-increment functionality in the MySQL database implemented in the Oracle database