CREATE TABLE CALENPREORCAGOP (
  NRCALENPREORCAGOP NUMBER(10) NOT NULL, 
  NRANOORCAGOP NUMBER(10) NOT NULL, 
  IDPERIODOORCA VARCHAR2(30) NOT NULL, 
  NRPERIODOORCA NUMBER(10) NOT NULL, 
  DTINICIOPRE DATE DEFAULT NULL NULL, 
  NRDIAAREALIZA NUMBER(10) DEFAULT NULL NULL, 
  NRDIAALERTA NUMBER(10) DEFAULT NULL NULL, 
  DSETAPA VARCHAR2(50) DEFAULT NULL NULL, 
  CDGRUPGERENTEOP VARCHAR2(10) 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_CALENPREORCAGOP PRIMARY KEY(NRCALENPREORCAGOP)
)
/
ALTER TABLE CALENPREORCAGOP ADD CONSTRAINT CKC_IDATIVO_CALENPREORCAGOP CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE CALENPREORCAGOP ADD CONSTRAINT CKC_IDPERIODOORCA_CALENPREORCA CHECK (IDPERIODOORCA IN ('MENSAL', 'BIMESTRAL', 'TRIMESTRAL', 'QUADRIMESTRAL', 'SEMESTRAL', 'ANUAL'))
/
ALTER TABLE PERCDETPRODFILGOP ADD CONSTRAINT FKGOP00681GRUPGERENTEOP FOREIGN KEY (CDGRUPGERENTEOP) REFERENCES GRUPGERENTEOP (CDGRUPGERENTEOP)
/
CREATE INDEX FKGOP00681GRUPGERENTEOP ON PERCDETPRODFILGOP(CDGRUPGERENTEOP)