CREATE TABLE DESPESASROP (
  NRFILIALROP NUMBER(10) NOT NULL, 
  NRDESPESASROP NUMBER(10) NOT NULL, 
  IDTPLANCROP VARCHAR2(255) NOT NULL, 
  IDTIPODESP VARCHAR2(30) DEFAULT NULL NULL, 
  CDFILIALCENT VARCHAR2(4) DEFAULT NULL NULL, 
  DTDESPESA DATE DEFAULT NULL NULL, 
  DTLANCAMENTO DATE DEFAULT NULL NULL, 
  CDDESPESA VARCHAR2(10) DEFAULT NULL NULL, 
  VRDESPESA DOUBLE PRECISION DEFAULT NULL NULL, 
  QTDESPESA DOUBLE PRECISION DEFAULT NULL NULL, 
  CDFILPARDESP VARCHAR2(4) DEFAULT NULL NULL, 
  NRLANCTONFROP VARCHAR2(10) DEFAULT NULL NULL, 
  NRSEQVENPAGROP VARCHAR2(2) DEFAULT NULL NULL, 
  NRPARCELAPAGROP VARCHAR2(2) DEFAULT NULL NULL, 
  CDFORNECED VARCHAR2(21) DEFAULT NULL NULL, 
  CDTIPOOPER VARCHAR2(2) DEFAULT NULL NULL, 
  NRNOTAFISC VARCHAR2(20) DEFAULT NULL NULL, 
  CDSERIE VARCHAR2(5) DEFAULT NULL NULL, 
  IDSTATUS VARCHAR2(1) DEFAULT NULL NULL, 
  DTINIREFEFAT DATE DEFAULT NULL NULL, 
  DTFINREFEFAT DATE DEFAULT NULL NULL, 
  NRSEQITPROD VARCHAR2(4) DEFAULT NULL NULL, 
  CDPRODUTO VARCHAR2(10) 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_DESPESASROP PRIMARY KEY(NRDESPESASROP)
)
/
ALTER TABLE DESPESASROP ADD CONSTRAINT CKC_IDTPLANCROP_DESPESASROP CHECK (IDTPLANCROP IN ('DESPESA', 'MAOOBRA', 'DEPRECIACAO'))
/
ALTER TABLE DESPESASROP ADD CONSTRAINT CKC_IDTIPODESP_DESPESASROP CHECK (IDTIPODESP IS NULL OR (IDTIPODESP IN ('MANUAL','CONTA_PAGAR','CONTABIL','LANC_ENTRADA')))
/
ALTER TABLE DESPESASROP ADD CONSTRAINT CKC_IDATIVO_DESPESASROP CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE DESPESASROP ADD CONSTRAINT FKGOP00714FILIALROP FOREIGN KEY (NRFILIALROP) REFERENCES FILIALROP (NRFILIALROP) ON DELETE CASCADE
/
CREATE INDEX FKGOP00714FILIALROP ON DESPESASROP (NRFILIALROP)