CREATE TABLE FREQPRODGRPRAT (
  NRFREQPRODGRPRAT NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  DTVIGENCIA DATE NOT NULL, 
  DSFREQPRODGRPRAT VARCHAR2(200) DEFAULT NULL 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 '1' NULL,
  CONSTRAINT PK_FREQPRODGRPRAT PRIMARY KEY(NRFREQPRODGRPRAT, NRORG)
)
/
ALTER TABLE FREQPRODGRPRAT ADD CONSTRAINT FKPLA00949FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE FREQPRODGRPRAT ADD CONSTRAINT FKPLA00950SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE FREQPRODGRPRAT ADD CONSTRAINT CKC_IDATIVO_FREQPRODGRPRAT CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX FKPLA00949FILIAL ON FREQPRODGRPRAT (CDFILIAL, NRORG)
/
CREATE INDEX FKPLA00950SERVICO ON FREQPRODGRPRAT (CDFILIAL, CDSERVFILI, NRORG)