CREATE TABLE VIGRESTPRODGR (
  NRVIGENCIA NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  DTVIGENCIA DATE NOT NULL, 
  DESCRICAO VARCHAR2(250) 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_VIGRESTPRODGR PRIMARY KEY(NRVIGENCIA)
)
/
ALTER TABLE VIGRESTPRODGR ADD CONSTRAINT CKC_IDATIVO_VIGRESTPRODGR CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE VIGRESTPRODGR ADD CONSTRAINT UN_VIGRESTPRODGR UNIQUE (CDFILIAL, DTVIGENCIA)
/
ALTER TABLE VIGRESTPRODGR ADD CONSTRAINT FKPLA00985FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKPLA00985FILIAL ON VIGRESTPRODGR (CDFILIAL)
/
ALTER TABLE RESTPRODGR ADD NRVIGENCIA NUMBER NULL
/
ALTER TABLE RESTPRODGR ADD CONSTRAINT FKPLA00986VIGRESTPRODGR FOREIGN KEY (NRVIGENCIA) REFERENCES VIGRESTPRODGR (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00986VIGRESTPRODGR ON RESTPRODGR (NRVIGENCIA)