ALTER TABLE CONFIGUFGNRE ADD IDVERSAO VARCHAR2(05)
/
UPDATE CONFIGUFGNRE
   SET IDVERSAO = '1.0'
 WHERE IDVERSAO IS NULL
/
COMMIT
/

ALTER TABLE CONFIGUFGNRE MODIFY IDVERSAO NOT NULL
/

ALTER TABLE CAMPOEXTRAGNRE DROP CONSTRAINT FKFIS00251CONFIGUF
/

DROP INDEX FKFIS00251_FK
/
 
ALTER TABLE CONFIGUFGNRE DROP CONSTRAINT PK_CONFIGUFGNRE 
/

DROP INDEX PK_CONFIGUFGNRE
/

ALTER TABLE CONFIGUFGNRE ADD CONSTRAINT PK_CONFIGUFGNRE
   PRIMARY KEY (SGUFFAVORECIDA, CDRECEITAGNRE, IDVERSAO)
/  

ALTER TABLE CAMPOEXTRAGNRE ADD IDVERSAO VARCHAR2(05)
/

UPDATE CAMPOEXTRAGNRE
   SET IDVERSAO = '1.0'
 WHERE IDVERSAO IS NULL
/
COMMIT
/

ALTER TABLE CAMPOEXTRAGNRE MODIFY IDVERSAO NOT NULL
/

ALTER TABLE CAMPOEXTRAGNRE DROP CONSTRAINT PK_CAMPOEXTRAGNRE
/

DROP INDEX PK_CAMPOEXTRAGNRE
/

ALTER TABLE CAMPOEXTRAGNRE ADD CONSTRAINT PK_CAMPOEXTRAGNRE
   PRIMARY KEY (SGUFFAVORECIDA, CDRECEITAGNRE, NRCODIGO, IDVERSAO)
/

CREATE INDEX FKFIS00251_FK ON CAMPOEXTRAGNRE (SGUFFAVORECIDA ASC, CDRECEITAGNRE ASC, IDVERSAO ASC)
/

ALTER TABLE CAMPOEXTRAGNRE 
   ADD CONSTRAINT FKFIS00251CONFIGUF FOREIGN KEY (SGUFFAVORECIDA, CDRECEITAGNRE, IDVERSAO)
     REFERENCES CONFIGUFGNRE (SGUFFAVORECIDA, CDRECEITAGNRE, IDVERSAO) ON DELETE CASCADE
/

ALTER TABLE MAPAAPURAC DROP CONSTRAINT FKFIS00003IMPOSTO
/

ALTER TABLE RELATIMPOS DROP CONSTRAINT FKFIS00007IMPOSTO
/