CREATE TABLE RATEIOAJUSTEMAPA (
    NRSEQRATEIO           NUMBER          NOT NULL,
	NRSEQUMAPAPU          VARCHAR2(10)	  NOT NULL,
	IDTPAJUSTE      	  VARCHAR2(05) 	  NOT NULL,   
	NRSEQAJUSTE    	      VARCHAR2(20) 	  NOT NULL,
	VRRATEIOAJ      	  FLOAT           NOT NULL,
    CDFILIRATEIO          VARCHAR2(04)    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_RATEIOAJUSTEMAPA CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT CKC_IDTPAJUSTE_RATEIOAJUSTEMAP CHECK (IDTPAJUSTE IN ('AC','ADB','ADI','ARB','DA','DD','DE','EC','ED','OC','OD','RC','RDI','VI','IA')),
        CONSTRAINT PK_RATEIOAJUSTEMAPA PRIMARY KEY (NRSEQRATEIO)
)
/

CREATE INDEX NOTAFISCAL_27 ON NOTAFISCAL (CDFILIEMIT, DTEMISSAO, IDENTRSAIDOP)
/

ALTER TABLE AJUSTFISCAUTO DROP CONSTRAINT CKC_IDTPAJUSTE_AJUSTFISCAUTO
/

ALTER TABLE AJUSTFISCAUTO ADD CONSTRAINT CKC_IDTPAJUSTE_AJUSTFISCAUTO CHECK(IDTPAJUSTE IN ('DE','OD','DD','OC','ED','EC','VI','IA'))
/