Du kan bruge en tabel, en sekvens til at generere unikke ID-værdier og en trigger.
For eksempel:
Tabel:
CREATE Table FITNESS_BMR
(
ID NUMBER NOT NULL PRIMARY KEY,
VALUE FLOAT NOT NULL,
VALUE_DATE DATE NOT NULL
);
Sekvens:create sequence t1_seq start with 1 increment by 1 nomaxvalue;
Udløser:
CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON FITNESS_BMR
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT t1_seq.nextval INTO :NEW.ID FROM dual;
END;
/