ALTER TABLE GERAPAPARCIAL MODIFY (
  CDCONTAINER VARCHAR2(5) DEFAULT NULL NULL
)
/
CREATE TABLE CARDACLIPLANPROD (
  NRCARDACLIPLANPROD NUMBER(10) NOT NULL, 
  NRPLANPROD NUMBER(10) NOT NULL, 
  CDPRODUTO VARCHAR2(10) NOT NULL, 
  CDPRATO VARCHAR2(10) NOT NULL, 
  CDFILAUXPRAT VARCHAR2(4) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  DTCONSUMO DATE NOT NULL, 
  CDCLIENTE VARCHAR2(21) DEFAULT NULL NULL, 
  CDDESTFILI VARCHAR2(3) DEFAULT NULL NULL, 
  CDTIPOPRAT VARCHAR2(2) NOT NULL, 
  QTCOMESTICLI NUMBER(10) NOT NULL, 
  NRSEQPRATCAR NUMBER(10) NOT NULL, 
  IDCOOKCHILL VARCHAR2(1) NOT NULL, 
  IDTPPRODCHILL VARCHAR2(30) NOT NULL, 
  IDESTADO VARCHAR2(30) NOT NULL, 
  CDCONTAINER VARCHAR2(5) DEFAULT NULL NULL, 
  QTAPRODUZIR NUMBER(10) DEFAULT NULL NULL, 
  QTEXTRA NUMBER(10) DEFAULT NULL NULL, 
  VRQTDEPRATEMB DOUBLE PRECISION DEFAULT NULL 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 NOT NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NOT NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NOT NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NOT NULL,
  CONSTRAINT PK_CARDACLIPLANPROD PRIMARY KEY(NRCARDACLIPLANPROD, NRORG)
)
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT FKPLA00928PLANPRODUCAO FOREIGN KEY (NRPLANPROD, NRORG) REFERENCES PLANPRODUCAO (NRPLANPROD, NRORG)
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT FKPLA00929PRODUTO FOREIGN KEY (CDPRODUTO, NRORG) REFERENCES PRODUTO (CDPRODUTO, NRORG)
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT FKPLA00930PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO, NRORG) REFERENCES PRATO (CDFILAUXPRAT, CDPRATO, NRORG)
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT FKPLA00931CONTAINER FOREIGN KEY (CDCONTAINER, NRORG) REFERENCES CONTAINER (CDCONTAINER, NRORG)
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT CKC_IDATIVO_CARDACLIPLANPROD CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT CKC_IDCOOKCHILL_CARDACLIPLAN CHECK (IDCOOKCHILL IN ('S','N'))
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT CKC_IDTPPRODCHILL_CARDACLIPL CHECK (IDTPPRODCHILL IN ('CONGELADO','RESFRIADO','NENHUM'))
/
ALTER TABLE CARDACLIPLANPROD ADD CONSTRAINT CKC_IDESTADO_CARDACLIPLAN CHECK (IDESTADO IN ('PRODUCAO', 'FINALIZACAO','CONSUMO'))
/
CREATE INDEX FKPLA00928PLANPRODUCAO ON CARDACLIPLANPROD (NRPLANPROD, NRORG)
/
CREATE INDEX FKPLA00929PRODUTO ON CARDACLIPLANPROD (CDPRODUTO, NRORG)
/
CREATE INDEX FKPLA00930PRATO ON CARDACLIPLANPROD (CDFILAUXPRAT, CDPRATO, NRORG)
/
CREATE INDEX FKPLA00931CONTAINER ON CARDACLIPLANPROD (CDCONTAINER, NRORG)
/
CREATE TABLE OBSCTRLEXPED (
  NROBSCTRLEXPED NUMBER(10) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  CDCENTRAL VARCHAR2(4) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  CDCLIENTE VARCHAR2(21) DEFAULT NULL NULL, 
  CDDESTFILI VARCHAR2(3) DEFAULT NULL NULL, 
  NRDIASEMANA VARCHAR2(1) NOT NULL, 
  DTVIGENCIA DATE NOT NULL, 
  DSOBSERVACAO VARCHAR2(500) NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NOT NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NOT NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NOT NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NOT NULL,
  CONSTRAINT PK_OBSCTRLEXPED PRIMARY KEY(NROBSCTRLEXPED, NRORG)
)
/
ALTER TABLE OBSCTRLEXPED ADD CONSTRAINT FKPLA00932SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE OBSCTRLEXPED ADD CONSTRAINT CKC_IDATIVO_OBSCTRLEXPED CHECK (IDATIVO IN ('S', 'N'))
/
CREATE INDEX FKPLA00932SERVICO ON OBSCTRLEXPED (CDFILIAL, CDSERVFILI, NRORG)