CREATE TABLE RETIRADADRO (
  NRFILIALROP NUMBER(10) NOT NULL, 
  NRRETIRADADRO NUMBER(10) NOT NULL, 
  CDGRUPPROD VARCHAR2(10) DEFAULT NULL NULL, 
  CDSUBGRPROD VARCHAR2(10) DEFAULT NULL NULL, 
  IDTPLANCROP VARCHAR2(30) NOT NULL, 
  VRLANCTOESTQ DOUBLE PRECISION DEFAULT NULL NULL, 
  CDFILIALCENT VARCHAR2(4) DEFAULT NULL NULL, 
  DTLANCAMENTO DATE DEFAULT NULL NULL, 
  DTRETICUSMOV DATE DEFAULT NULL NULL, 
  QTLANCTOEST DOUBLE PRECISION DEFAULT NULL NULL, 
  CDSERVFILI VARCHAR2(5) 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_RETIRADADRO PRIMARY KEY(NRRETIRADADRO)
)
/
ALTER TABLE RETIRADADRO ADD CONSTRAINT CKC_IDTPLANCROP_RETIRADADRO CHECK (IDTPLANCROP IN ('RETIRADA_ESTOQ', 'RETIRADA_PLA'))
/
ALTER TABLE RETIRADADRO ADD CONSTRAINT CKC_IDATIVO_RETIRADADRO CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE RETIRADADRO ADD CONSTRAINT FKGOP00712FILIALROP FOREIGN KEY (NRFILIALROP) REFERENCES FILIALROP (NRFILIALROP) ON DELETE CASCADE
/
CREATE INDEX FKGOP00712FILIALROP ON RETIRADADRO (NRFILIALROP)