Vytvoření tabulky s autoincrementem (sekvence a trigger)

CREATE TABLE TABULKA (
     ID NUMBER     
, JMENO VARCHAR2(20)     
, PRIJMENI VARCHAR2(20)
);
COMMENT ON TABLE TABULKA IS 'popis tabulky';  
COMMENT ON COLUMN TABULKA.ID IS 'jednoznacna identifikace';
COMMENT ON COLUMN TABULKA.JMENO IS 'nejaky sloupec 1';
COMMENT ON COLUMN TABULKA.PRIJMENI IS 'nejaky sloupec 2';
ALTER TABLE TABULKA ADD (CONSTRAINT TABULKA_PK PRIMARY KEY (ID));
CREATE SEQUENCE TABULKA_SEQ START WITH 1;
CREATE OR REPLACE TRIGGER TABULKA_TRG   
BEFORE INSERT ON TABULKA
      FOR EACH ROW
              BEGIN
                   SELECT TABULKA_SEQ.NEXTVAL                   
INTO :new.id                   
FROM dual;
              END;
/
Vlastimil Pošmura, 2019