Step for creating the auto-increment ID field in the oracle database, oracle Field
The steps for using the auto-increment ID field in oracle are complex and summarized as follows:
-- Create a table
Create table advice (id int not null, active int default 1 not null, type int not null, MSG VARCHAR2 (512) not null, ADVICE VARCHAR2 (4000) not null, primary key (ID), CONSTRAINT ADVICE_UNI UNIQUE (TYPE, MSG) tablespace mydb; -- create an auto-incrementing ID named: table name_field name_seqcreate SEQUENCE ADVICE_ID_SEQ MINVALUE 1 nomaxvalue increment by 1 start with 1 NOCACHE; -- create a trigger for the Insert operation without writing NEXTVAL in the SQL statement, the table name is _ INS_TRGCREATE or replace trigger ADVICE_INS_TRG before insert on advice for each row when (NEW. id is null) BEGINSELECT ADVICE_ID_SEQ.NEXTVAL INTO: NEW. id from dual; END;
How to automatically add Oracle Database IDS
Create Sequence create sequence you must first have CREATE Sequence or Create ANY: = next_id; end; in this way, you do not need to specify the value of the column you want to auto-increment when inserting data ..
When you use java to add a record to an oracle database, an id field automatically increases.
The id automatically increases, and the value can be directly assigned to null in the program.