CREATE TABLE GRSCOLEPRFORNOL (
  NRCOLEPRFORNOL VARCHAR2(10) NOT NULL, 
  CDFORNECED VARCHAR2(21) NOT NULL, 
  DTCOLEPRFORNOL DATE NOT NULL, 
  DTINIVALFORNOL DATE DEFAULT NULL NULL, 
  DTFINVALFORNOL DATE DEFAULT NULL NULL, 
  CDOPERADOR VARCHAR2(12) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT NULL NULL,
  CONSTRAINT PK_GRSCOLEPRFORNOL PRIMARY KEY(NRCOLEPRFORNOL)
)
/
ALTER TABLE GRSCOLEPRFORNOL ADD CONSTRAINT FK_GRSCOLEPRFORNOL_FORN FOREIGN KEY (CDFORNECED) REFERENCES FORNECEDOR (CDFORNECED)
/
ALTER TABLE GRSCOLEPRFORNOL ADD CONSTRAINT FK_GRSCOLEPRFORNOL_OPER FOREIGN KEY (CDOPERADOR) REFERENCES OPERADOR (CDOPERADOR)
/
ALTER TABLE GRSCOLEPRFORNOL ADD CONSTRAINT CKC_IDATIVO_GRSCOLEPRFORNOL CHECK (IDATIVO IN ('S', 'N'))
/
CREATE INDEX FK_GRSCOLEPRFORNOL_OPER ON GRSCOLEPRFORNOL (CDOPERADOR)
/
CREATE INDEX GRSCOLEPRFORNOL_01 ON GRSCOLEPRFORNOL (CDFORNECED, DTINIVALFORNOL DESC,  DTFINVALFORNOL DESC)