CREATE TABLE ANXLIMPESERGR (
  NRANEXO NUMBER(10) NOT NULL, 
  NRVIGENCIA NUMBER(10) NOT NULL, 
  DSDOCUMENTOANEXO VARCHAR2(4000) NOT NULL, 
  DOCUMENTOANEXO VARCHAR2(4000) NOT 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_ANXLIMPESERGR PRIMARY KEY(NRANEXO)
)
/
ALTER TABLE ANXLIMPESERGR ADD CONSTRAINT CKC_IDATIVO_ANXLIMPESERGR CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE ANXLIMPESERGR ADD CONSTRAINT UN_ANXLIMPESERGR UNIQUE (NRVIGENCIA, DOCUMENTOANEXO)
/
ALTER TABLE ANXLIMPESERGR ADD CONSTRAINT FKPLA00989VIGLIMPESERGR FOREIGN KEY (NRVIGENCIA) REFERENCES VIGLIMPESERGR (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00989VIGLIMPESERGR ON ANXLIMPESERGR (NRVIGENCIA)
/
ALTER TABLE FREQPRODGRPRAT MODIFY NRVIGENCIA NOT NULL
/
CREATE TABLE ANXFREQPRODGRPRAT (
  NRANEXO NUMBER(10) NOT NULL, 
  NRVIGENCIA NUMBER(10) NOT NULL, 
  DSDOCUMENTOANEXO VARCHAR2(4000) DEFAULT NULL NULL, 
  DOCUMENTOANEXO VARCHAR2(4000) 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_ANXFREQPRODGRPRAT PRIMARY KEY(NRANEXO)
)
/
ALTER TABLE ANXFREQPRODGRPRAT ADD CONSTRAINT CKC_IDATIVO_ANXFREQPRODGRPRAT CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE ANXFREQPRODGRPRAT ADD CONSTRAINT UN_ANXFREQPRODGRPRAT UNIQUE (NRVIGENCIA, DOCUMENTOANEXO)
/
ALTER TABLE ANXFREQPRODGRPRAT ADD CONSTRAINT FKPLA00990VIGFREQPRODGRPRAT FOREIGN KEY (NRVIGENCIA) REFERENCES VIGFREQPRODGRPRAT (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00990VIGFREQPRODGRPRAT ON ANXFREQPRODGRPRAT (NRVIGENCIA)
/
ALTER TABLE FREQPRATMES MODIFY NRVIGENCIA NOT NULL