ALTER TABLE CARDAPIOBASE ADD IDSERVICOFIXO VARCHAR2(1) NULL
/
ALTER TABLE CARDAPIOBASE ADD CONSTRAINT CKC_IDSERVICOFIXO_CARDAPIOBASE CHECK (IDSERVICOFIXO IN ('N', 'S'))
/

CREATE TABLE EVENTOCARDTRAB
(
	NREVENTOCARDTRAB  NUMBER NOT NULL,
	NRCARDAPIOTRAB	  NUMBER NOT NULL,
	CDMES 			  VARCHAR2(2) NOT NULL,
	DSEVENTO 		  VARCHAR2(100) NOT NULL,
	VRPERCENTUAL 	  FLOAT NOT NULL,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_EVENTOCARDTRAB CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_EVENTOCARDTRAB PRIMARY KEY (NREVENTOCARDTRAB),
		CONSTRAINT CKC_CDMES_EVENTOCARDTRAB CHECK (CDMES IN ('01','02','03','04','05','06','07','08','09','10','11','12'))
)
/

ALTER TABLE EVENTOCARDTRAB ADD CONSTRAINT FKPLA01309CARDAPIOTRAB FOREIGN KEY  (NRCARDAPIOTRAB)
    REFERENCES CARDAPIOTRAB (NRCARDAPIOTRAB) ON DELETE CASCADE
/

CREATE INDEX FKPLA01309CARDAPIOTRAB ON EVENTOCARDTRAB(NRCARDAPIOTRAB)
/