CREATE TABLE VIGLIMPESERGR (
  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_VIGLIMPESERGR PRIMARY KEY(NRVIGENCIA)
)
/
ALTER TABLE VIGLIMPESERGR ADD CONSTRAINT CKC_IDATIVO_VIGLIMPESERGR CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE VIGLIMPESERGR ADD CONSTRAINT UN_VIGLIMPESERGR UNIQUE (CDFILIAL, DTVIGENCIA)
/
ALTER TABLE VIGLIMPESERGR ADD CONSTRAINT FKPLA00979FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKPLA00979FILIAL ON VIGLIMPESERGR (CDFILIAL)
/
ALTER TABLE LIMPESERGR ADD NRVIGENCIA NUMBER NULL
/
ALTER TABLE LIMPESERGR ADD CONSTRAINT FKPLA00980VIGLIMPESERGR FOREIGN KEY (NRVIGENCIA) REFERENCES VIGLIMPESERGR (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00980VIGLIMPESERGR ON LIMPESERGR (NRVIGENCIA)
/
CREATE TABLE VIGFREQPRODGRPRAT (
  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_VIGFREQPRODGRPRAT PRIMARY KEY(NRVIGENCIA)
)
/
ALTER TABLE VIGFREQPRODGRPRAT ADD CONSTRAINT CKC_IDATIVO_VIGFREQPRODGRPRAT CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE VIGFREQPRODGRPRAT ADD CONSTRAINT UN_VIGFREQPRODGRPRAT UNIQUE (CDFILIAL, DTVIGENCIA)
/
CREATE INDEX FKPLA00981FILIAL ON VIGFREQPRODGRPRAT (CDFILIAL)