CREATE TABLE DEDUCAOROP (
  NRFILIALROP NUMBER(10) NOT NULL, 
  NRDEDUCAOROP NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  DTREFERENC DATE NOT NULL, 
  NRNOTAFISC VARCHAR2(20) DEFAULT NULL NULL, 
  CDIMPOSTO VARCHAR2(2) DEFAULT NULL NULL, 
  CDENCARGO VARCHAR2(2) DEFAULT NULL NULL, 
  DSDEDUCAO VARCHAR2(100) DEFAULT NULL NULL, 
  CDCLIENTE VARCHAR2(21) DEFAULT NULL NULL, 
  CDFILIALBENE VARCHAR2(4) DEFAULT NULL NULL, 
  CDFORNECED VARCHAR2(21) DEFAULT NULL NULL, 
  DSBENEFICIARIO VARCHAR2(100) DEFAULT NULL NULL, 
  CDFILIALLANC VARCHAR2(4) DEFAULT NULL NULL, 
  NRLANCTONF VARCHAR2(10) DEFAULT NULL NULL, 
  NRRECEXTRAFILI NUMBER(10) DEFAULT NULL NULL, 
  IDTPLANCROP VARCHAR2(30) NOT NULL, 
  CDFILIALCENT VARCHAR2(4) DEFAULT NULL NULL, 
  VRDEDUCAO DOUBLE PRECISION DEFAULT NULL NULL, 
  VRPERFIXCALCIMP DOUBLE PRECISION DEFAULT NULL NULL, 
  NRORG NUMBER(10) DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU NUMBER(10) DEFAULT 1 NULL,
  CONSTRAINT PK_DEDUCAOROP PRIMARY KEY(NRDEDUCAOROP)
)
/
ALTER TABLE DEDUCAOROP ADD CONSTRAINT CKC_IDTPLANCROP_DEDUCAOROP CHECK (IDTPLANCROP IN ('FAT_EFETIVO', 'FAT_NOTAFISCAL', 'FAT_FORSALE', 'FAT_DIVERSOS', 'RECEITA_EXTRA'))
/
ALTER TABLE DEDUCAOROP ADD CONSTRAINT CKC_IDATIVO_DEDUCAOROP CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE DEDUCAOROP ADD CONSTRAINT FKGOP00709FILIALROP FOREIGN KEY (NRFILIALROP) REFERENCES FILIALROP (NRFILIALROP) ON DELETE CASCADE
/
ALTER TABLE DEDUCAOROP ADD CONSTRAINT FKGOP00710FILIALROP FOREIGN KEY (NRRECEXTRAFILI) REFERENCES RECEXTRAFILI (NRRECEXTRAFILI)
/
CREATE INDEX FKGOP00709FILIALROP ON DEDUCAOROP (NRFILIALROP)
/
CREATE INDEX FKGOP00710FILIALROP ON DEDUCAOROP (NRRECEXTRAFILI)