CREATE TABLE FCT_LOG_APURAMEDAUTO ( 
    NRLOGMEDICAOAUTO  NUMBER  NOT NULL,
    NRMEDICAOFATURA   NUMBER,
    NRSEQCONTRATO     NUMBER, 
    NRFATURACONT      NUMBER,
    TXLOG             CLOB , 
    NRORG             NUMBER 	             DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)            DEFAULT 'S'  NOT NULL
		CONSTRAINT CKC_IDATIVO_FCT_LOGAPURAUTO CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  			      NULL,
    DTULTATU          DATE                  			      NULL,
    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'
)
/

CREATE INDEX SM00272_FK ON FCT_LOG_APURAMEDAUTO (NRMEDICAOFATURA ASC)
/
 
ALTER TABLE FCT_LOG_APURAMEDAUTO
  ADD CONSTRAINT FKSM00272MEDFATURA FOREIGN KEY (NRMEDICAOFATURA)
      REFERENCES FCT_MEDICAOFATURA (NRMEDICAOFATURA) ON DELETE CASCADE
/

CREATE INDEX SM00273_FK ON FCT_LOG_APURAMEDAUTO (NRSEQCONTRATO ASC)
/

ALTER TABLE FCT_LOG_APURAMEDAUTO
  ADD CONSTRAINT FKSM00273CONTRATO FOREIGN KEY (NRSEQCONTRATO)
      REFERENCES FCT_CONTRATO (NRSEQCONTRATO) ON DELETE CASCADE
/

CREATE INDEX SM00274_FK ON FCT_LOG_APURAMEDAUTO (NRFATURACONT ASC)
/

ALTER TABLE FCT_LOG_APURAMEDAUTO
  ADD CONSTRAINT FKSM00274FATURACONT FOREIGN KEY (NRFATURACONT)
      REFERENCES FCT_FATURACONT (NRFATURACONT) ON DELETE CASCADE