CREATE TABLE DESTPREVCONSINF (
  NRDESTPREVCONSINF NUMBER(10) NOT NULL, 
  NRINSUMOPREVCONSINF NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDCIA VARCHAR2(4) NOT NULL, 
  NRVOO VARCHAR2(5) NOT NULL, 
  CDTRECHO VARCHAR2(4) NOT NULL, 
  DTATENDIMENTO DATE NOT NULL, 
  DTPRODUCAO DATE NOT NULL, 
  NRSERVICOCIAFILIP NUMBER(10) NOT NULL, 
  CDMANCIA VARCHAR2(4) NOT NULL, 
  NRSERVICOCIAFILI NUMBER(10) NOT NULL, 
  CDCLASSE VARCHAR2(4) NOT NULL, 
  CDSUBGRU VARCHAR2(10) NOT NULL, 
  NRSEQSUBGRUSEMAM NUMBER(10) NOT NULL, 
  CDCICLO VARCHAR2(4) NOT NULL, 
  NRTIPOPROD NUMBER(10) NOT NULL, 
  NRTIPONEGOCIOINF NUMBER(10) NOT NULL, 
  CDRECEITAMENU VARCHAR2(10) DEFAULT NULL NULL, 
  CDRECEITADEST VARCHAR2(10) DEFAULT NULL NULL, 
  CDRECEITA VARCHAR2(10) DEFAULT NULL NULL, 
  CDSETOR VARCHAR2(4) DEFAULT NULL NULL, 
  NRTURNO VARCHAR2(2) DEFAULT NULL NULL, 
  NRCATEGORIAPROD NUMBER(10) DEFAULT NULL NULL, 
  NRSUBCATEGORIAPROD NUMBER(10) DEFAULT NULL NULL, 
  QTINSUMOCALC DOUBLE PRECISION NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 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, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_DESTPREVCONSINF PRIMARY KEY(NRDESTPREVCONSINF, NRORG)
)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00770INSUMOPREVCONSINF FOREIGN KEY (NRINSUMOPREVCONSINF, NRORG) REFERENCES INSUMOPREVCONSINF (NRINSUMOPREVCONSINF, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00771VOOTRECHO FOREIGN KEY (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRORG) REFERENCES VOOTRECHO (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00772MANUALCIAM FOREIGN KEY (CDFILIAL, CDCIA, CDMANCIA, NRORG) REFERENCES MANUALCIAM (CDFILIAL, CDCIA, CDMANCIA, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00773SERVICOCIAFILI FOREIGN KEY (CDFILIAL, CDCIA, NRSERVICOCIAFILI, NRORG) REFERENCES SERVICOCIAFILI (CDFILIAL, CDCIA, NRSERVICOCIAFILI, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00774SERVICOCIAFILI FOREIGN KEY (CDFILIAL, CDCIA, NRSERVICOCIAFILIP, NRORG) REFERENCES SERVICOCIAFILI (CDFILIAL, CDCIA, NRSERVICOCIAFILI, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00775CLASSE FOREIGN KEY (CDCLASSE, NRORG) REFERENCES CLASSE (CDCLASSE, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00776SUBGRUPOM FOREIGN KEY (CDSUBGRU, NRORG) REFERENCES SUBGRUPOM (CDSUBGRU, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00777CICLO FOREIGN KEY (CDCICLO, NRORG) REFERENCES CICLO (CDCICLO, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00778TIPOPROD FOREIGN KEY (NRTIPOPROD, NRORG) REFERENCES TIPOPROD (NRTIPOPROD, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00779TIPONEGOCIOINF FOREIGN KEY (NRTIPONEGOCIOINF, NRORG) REFERENCES TIPONEGOCIOINF (NRTIPONEGOCIOINF, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00780RECEITAM FOREIGN KEY (CDRECEITAMENU, NRORG) REFERENCES RECEITAM (CDRECEITA, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00781RECEITAM FOREIGN KEY (CDRECEITADEST, NRORG) REFERENCES RECEITAM (CDRECEITA, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00782RECEITAM FOREIGN KEY (CDRECEITA, NRORG) REFERENCES RECEITAM (CDRECEITA, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00783SETOR FOREIGN KEY (CDSETOR, NRORG) REFERENCES SETOR (CDSETOR, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00784TURNO FOREIGN KEY (NRTURNO, NRORG) REFERENCES TURNO (NRTURNO, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00785CATEGORIAPROD FOREIGN KEY (NRCATEGORIAPROD, NRORG) REFERENCES CATEGORIAPROD (NRCATEGORIAPROD, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT FKCOC00786CATEGORIAPROD FOREIGN KEY (NRSUBCATEGORIAPROD, NRORG) REFERENCES CATEGORIAPROD (NRCATEGORIAPROD, NRORG)
/
ALTER TABLE DESTPREVCONSINF ADD CONSTRAINT CKC_IDATIVO_DESTPREVCONSINF CHECK (IDATIVO IN ('S', 'N'))