CREATE TABLE ANXFREQPRATMES (
  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(255) 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_ANXFREQPRATMES PRIMARY KEY(NRANEXO)
)
/
ALTER TABLE ANXFREQPRATMES ADD CONSTRAINT CKC_IDATIVO_ANXFREQPRATMES CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE ANXFREQPRATMES ADD CONSTRAINT UN_ANXFREQPRATMES UNIQUE (NRVIGENCIA, DOCUMENTOANEXO)
/
ALTER TABLE ANXFREQPRATMES ADD CONSTRAINT FKPLA00991VIGFREQPRATMES FOREIGN KEY (NRVIGENCIA) REFERENCES VIGFREQPRATMES (NRVIGENCIA) ON DELETE CASCADE
/
CREATE INDEX FKPLA00991VIGFREQPRATMES ON ANXFREQPRATMES (NRVIGENCIA)
/
ALTER TABLE RESTPRODGR MODIFY NRVIGENCIA NOT NULL
/
CREATE TABLE ANXRESTPRODGR (
  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_ANXRESTPRODGR PRIMARY KEY(NRANEXO)
)
/
ALTER TABLE ANXRESTPRODGR ADD CONSTRAINT CKC_IDATIVO_ANXRESTPRODGR CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE ANXRESTPRODGR ADD CONSTRAINT UN_ANXRESTPRODGR UNIQUE (NRVIGENCIA, DOCUMENTOANEXO)
/
ALTER TABLE ANXRESTPRODGR ADD CONSTRAINT FKPLA00992VIGRESTPRODGR FOREIGN KEY (NRVIGENCIA) REFERENCES VIGRESTPRODGR (NRVIGENCIA) ON DELETE CASCADE