CREATE TABLE alertacfg( 
    EMPRES_CODIGO	varchar(4) NOT NULL,
    FILIAL_CODIGO	varchar(4) NOT NULL,
    ALERTACFG_SEQ   BIGINT IDENTITY(1,1) NOT NULL,
    ALERTACFG_MSG   TEXT,
    ALERTACFG_DESC VARCHAR(60),
    ALERTACFG_SELECT TEXT,
    ALERTACFG_CONDICAO VARCHAR(20),
    ALERTACFG_DESTINATARIOS TEXT,
    ALERTACFG_STATUS DECIMAL(2,0),
    ALERTACFG_NIVEL DECIMAL(2,0)
    PRIMARY KEY(EMPRES_CODIGO,FILIAL_CODIGO,ALERTACFG_SEQ)
);

--SCRIPT PARA ORACLE
CREATE TABLE alertacfg (
    EMPRES_CODIGO	varchar(4) NOT NULL,
    FILIAL_CODIGO	varchar(4) NOT NULL,
    ALERTACFG_SEQ   NUMBER(20,0) NOT NULL,
    ALERTACFG_MSG   VARCHAR2(250),
    ALERTACFG_DESC VARCHAR(60),
    ALERTACFG_SELECT VARCHAR2(2000),
    ALERTACFG_CONDICAO VARCHAR(20),
    ALERTACFG_DESTINATARIOS VARCHAR2(2000),
    ALERTACFG_STATUS DECIMAL(2,0),
    ALERTACFG_NIVEL DECIMAL(2,0)
)
  TABLESPACE users
/

ALTER TABLE alertacfg
  ADD PRIMARY KEY (
    ALERTACFG_SEQ
  )
  USING INDEX
    TABLESPACE users
/

CREATE SEQUENCE seq_alertacfg
  MINVALUE 1
  MAXVALUE 999999999999999999999999999
  INCREMENT BY 1
  NOCYCLE
  NOORDER
  CACHE 20
/


CREATE OR REPLACE TRIGGER tg_bi_alertacfg
BEFORE INSERT
    ON alertacfg
    FOR EACH ROW

DECLARE
BEGIN
   SELECT seq_alertacfg.NEXTVAL
   INTO :NEW.ALERTACFG_SEQ FROM dual;
EXCEPTION
    WHEN OTHERS THEN ROLLBACK;
END;
/