CREATE TABLE CONSUMOROP (
  NRFILIALROP NUMBER(10) NOT NULL, 
  NRCONSUMOROP NUMBER(10) NOT NULL, 
  CDGRUPPROD VARCHAR2(10) NOT NULL, 
  CDSUBGRPROD VARCHAR2(10) DEFAULT NULL NULL, 
  IDTPLANCROP VARCHAR2(30) NOT NULL, 
  DTLANCAMENTO DATE DEFAULT NULL NULL, 
  DTCONSUMROP DATE DEFAULT NULL NULL, 
  CDCLIENTEROP VARCHAR2(21) DEFAULT NULL NULL, 
  CDTIPOOPERROP VARCHAR2(2) DEFAULT NULL NULL, 
  NRNOTAFISCROP VARCHAR2(20) DEFAULT NULL NULL, 
  CDSERIENFROP VARCHAR2(5) DEFAULT NULL NULL, 
  CDFILIALNFROP VARCHAR2(4) DEFAULT NULL NULL, 
  NRLANCTONFROP VARCHAR2(10) DEFAULT NULL NULL, 
  CDFILCENTROP VARCHAR2(4) DEFAULT NULL NULL, 
  IDSTATUSROP VARCHAR2(1) DEFAULT NULL NULL, 
  DTINIREFEROP DATE DEFAULT NULL NULL, 
  DTFINREFEROP DATE DEFAULT NULL NULL, 
  NUMEROREROP VARCHAR2(10) DEFAULT NULL NULL, 
  QTITEMLANCROP DOUBLE PRECISION DEFAULT NULL NULL, 
  VRITEMLANCROP DOUBLE PRECISION DEFAULT NULL NULL, 
  VRCUSTOLOGITROP DOUBLE PRECISION DEFAULT NULL NULL, 
  VRCUSTSEGPROD 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 VARCHAR2(12) DEFAULT '1' NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_CONSUMOROP PRIMARY KEY(NRCONSUMOROP)
)
/
ALTER TABLE CONSUMOROP ADD CONSTRAINT CKC_IDTPLANCROP_CONSUMOROP CHECK (IDTPLANCROP IN ('CONSUMO_ENTRADA', 'CONSUMO_SAIDA'))
/
ALTER TABLE CONSUMOROP ADD CONSTRAINT CKC_IDATIVO_CONSUMOROP CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE CONSUMOROP ADD CONSTRAINT FKGOP00713FILIALROP FOREIGN KEY (NRFILIALROP) REFERENCES FILIALROP (NRFILIALROP) ON DELETE CASCADE
/
CREATE INDEX FKGOP00713FILIALROP ON CONSUMOROP (NRFILIALROP)