Anda dapat menggunakan tabel, urutan untuk menghasilkan nilai ID unik dan pemicu.
Misalnya:
Tabel:
CREATE Table FITNESS_BMR
(
ID NUMBER NOT NULL PRIMARY KEY,
VALUE FLOAT NOT NULL,
VALUE_DATE DATE NOT NULL
);
Urutan:create sequence t1_seq start with 1 increment by 1 nomaxvalue;
Pemicu:
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;
/