oracle autoincrement with sequence and trigger is not working correctly

前端 未结 2 625
盖世英雄少女心
盖世英雄少女心 2020-12-07 03:53

here is my problemI have this code to make an autoincrement variable in oracle database:

CREATE TABLE Korisnici
    (
        id_korisnika number PRIMARY KEY         


        
2条回答
  •  天命终不由人
    2020-12-07 04:27

    Specifying the SEQUENCE with NOCACHE will stop a session caching 20 numbers at a time and help.

    create sequence test_seq
    start with 1 
    increment by 1
    NOCACHE;
    

    However, if you're hoping for a completely contiguous sequence this is very difficult to achieve - numbers taken from the sequence are "lost" if (for example) an insert is rolled back.


    Based on your comment, I wonder if you're forgetting to COMMIT?

提交回复
热议问题