CREATE TABLE VIGFREQGRPRATMES (
  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_VIGFREQGRPRATMES PRIMARY KEY(NRVIGENCIA)
)
/
ALTER TABLE VIGFREQGRPRATMES ADD CONSTRAINT CKC_IDATIVO_VIGFREQGRPRATMES CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE VIGFREQGRPRATMES ADD CONSTRAINT UN_VIGFREQGRPRATMES UNIQUE (CDFILIAL, DTVIGENCIA)
/
ALTER TABLE VIGFREQGRPRATMES ADD CONSTRAINT FKPLA00975FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKPLA00975FILIAL ON VIGFREQGRPRATMES (CDFILIAL)
/
ALTER TABLE FREQGRPRATMES ADD NRVIGENCIA NUMBER NULL
/
ALTER TABLE FREQGRPRATMES ADD CONSTRAINT FKPLA00976VIGFREQGRPRATMES FOREIGN KEY (NRVIGENCIA) REFERENCES VIGFREQGRPRATMES (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00976VIGFREQGRPRATMES ON FREQGRPRATMES (NRVIGENCIA)