--oracle implement self-increment id--create a T _studentinfo table The CREATE TABLE t_studentinfo ("id" integer NOT NULL primary key, Xsname NVARCHAR2 (+) NOT NULL, Xsage integer NOT NULL, Mobile varchar (n), Email varchar (+), Address nvarchar2 (300));--Create a Sequence, the sequence name is called seq_studentinfo_identity--to create a sequence (the rules for sequence names are generally recommended to start with SEQ, then underline, followed by your table name, t_ before the table name can be removed, and then end with _identity, Used to indicate that this sequence is used in the sequence of ID self-increment fields) create sequence seq_studentinfo_identity increment by 1--each time I add a few, I'm adding 1 s each time Tart with 1--counting Nomaxvalue starting from 1--not setting the maximum value nocycle--always accumulate, not cycle nocache; --Do not build buffers--you only have tables and sequences that are not enough, and you need a trigger to execute it--to create a trigger trigger whose name is trg_studentinfo_identity--I recommend that triggers start with TRG, followed by the table name, In the back, depending on the situation, see for yourself. Create Trigger trg_studentinfo_identity BeforeInsert on T_studentinfo for each row if (New.id is null) begins Elect Id_sequence.nextval into:new.id from Dual;end;
Http://www.2cto.com/database/201305/214692.html