CREATE TABLE PARAMCODAJUS (	
  CODAJUSTE 		VARCHAR2(15 ) 			NOT NULL , 
  CDIMPOSTONFE 		VARCHAR2(20 ) 			NOT NULL , 
  CDCONTAJCRED 		VARCHAR2(20 ), 
  CDCONTAJDEB 		VARCHAR2(20 ), 
  CDCONTRECOL 		VARCHAR2(20 ), 
  IDCONTCTBL 		VARCHAR2(1 ), 
  CDCONTRATEIO 		VARCHAR2(20 ), 
  NRORG             NUMBER 	     			DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     		DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_PARAMCODAJUS 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' ,
  	 CONSTRAINT CKC_IDCONTCTBL_PARAMCODAJUS CHECK (IDCONTCTBL IN ('S','N')) , 
  	 CONSTRAINT PK_PARAMCODAJUS PRIMARY KEY (CDIMPOSTONFE, CODAJUSTE)
)
/
  CREATE TABLE PARAMAJUSTE  (	
    NRSEQPARAMAJUSTE 	VARCHAR2(10 ) 			NOT NULL , 
    IDTPAJUSTE 			VARCHAR2(3 ) 			NOT NULL , 
    NMAJUSTE 			VARCHAR2(50 ) 			NOT NULL , 
    CDIMPOSTONFE 		VARCHAR2(20 ) 			NOT NULL , 
    CDCONTAJCRED 		VARCHAR2(20 ), 
    CDCONTAJDEB 		VARCHAR2(20 ), 
    CDCONTRECOL 		VARCHAR2(20 ), 
    IDCONTCTBL 			VARCHAR2(1 ), 
    CDCONTRATEIO 		VARCHAR2(20 ), 
    NRORG             	NUMBER 	     			DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_PARAMAJUSTE 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', 
		CONSTRAINT CKC_IDCONTCTBL_PARAMAJUSTE CHECK (IDCONTCTBL IN ('S','N')) , 
		CONSTRAINT UN_PARAMAJUSTE UNIQUE (CDIMPOSTONFE, IDTPAJUSTE),
		CONSTRAINT PK_PARAMAJUSTE PRIMARY KEY (NRSEQPARAMAJUSTE),
		CONSTRAINT FKFIS00782CONTCTBL FOREIGN KEY (CDCONTAJCRED)
			REFERENCES CONTCTBL (CDCONTCTBL), 
		CONSTRAINT FKFIS00783CONTCTBL FOREIGN KEY (CDCONTAJDEB)
			REFERENCES CONTCTBL (CDCONTCTBL), 
		CONSTRAINT FKFIS00784CONTCTBL FOREIGN KEY (CDCONTRECOL)
			REFERENCES CONTCTBL (CDCONTCTBL) 
)
/
CREATE INDEX FIS00782_FK ON PARAMAJUSTE (CDCONTAJCRED ASC) 
/
CREATE INDEX FIS00783_FK ON PARAMAJUSTE (CDCONTAJDEB ASC) 
/
CREATE INDEX FIS00784_FK ON PARAMAJUSTE (CDCONTRECOL ASC) 
/
ALTER TABLE CFOPPADRAO ADD DSCFOPLMAG VARCHAR(200)
/