CREATE TABLE VIGFREQOPCAGR (
  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_VIGFREQOPCAGR PRIMARY KEY(NRVIGENCIA)
)
/
ALTER TABLE VIGFREQOPCAGR ADD CONSTRAINT CKC_IDATIVO_VIGFREQOPCAGR CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE VIGFREQOPCAGR ADD CONSTRAINT UN_VIGFREQOPCAGR UNIQUE (CDFILIAL, DTVIGENCIA)
/
ALTER TABLE VIGFREQOPCAGR ADD CONSTRAINT FKPLA00977FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKPLA00977FILIAL ON VIGFREQOPCAGR (CDFILIAL)
/
ALTER TABLE FREQOPCAGR ADD NRVIGENCIA NUMBER NULL
/
ALTER TABLE FREQOPCAGR ADD CONSTRAINT FKPLA00978VIGFREQOPCAGR FOREIGN KEY (NRVIGENCIA) REFERENCES VIGFREQOPCAGR (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00978VIGFREQOPCAGR ON FREQOPCAGR (NRVIGENCIA)