CREATE TABLE INVENTARIOROP (
  NRFILIALROP NUMBER(10) NOT NULL, 
  NRINVENTARIOROP NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDGRUPPROD VARCHAR2(10) DEFAULT NULL NULL, 
  CDSUBGRPROD VARCHAR2(10) DEFAULT NULL NULL, 
  IDTPLANCROP VARCHAR2(30) NOT NULL, 
  VRITEMLANCROP DOUBLE PRECISION DEFAULT NULL NULL, 
  CDFILIALCENT VARCHAR2(4) DEFAULT NULL NULL, 
  DTINVENTARIO DATE DEFAULT NULL NULL, 
  DTLANCAMENT DATE DEFAULT NULL NULL, 
  QTESTDIACON 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_INVENTARIOROP PRIMARY KEY(NRINVENTARIOROP)
)
/
ALTER TABLE INVENTARIOROP ADD CONSTRAINT CKC_IDTPLANCROP_INVENTARIOROP CHECK (IDTPLANCROP IN ('INV_INICIAL', 'INV_FINAL', 'IMPLANTACAO', 'AJUSTE'))
/
ALTER TABLE INVENTARIOROP ADD CONSTRAINT CKC_IDATIVO_INVENTARIOROP CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE INVENTARIOROP ADD CONSTRAINT FKGOP00711FILIALROP FOREIGN KEY (NRFILIALROP) REFERENCES FILIALROP (NRFILIALROP) ON DELETE CASCADE
/
CREATE INDEX FKGOP00711FILIALROP ON INVENTARIOROP (NRFILIALROP)