CREATE TABLE FREQGRPRATMES (
  NRFREQGRPRATMES NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  DTVIGENCIA DATE NOT NULL, 
  DSFREQGRPRATMES 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_FREQGRPRATMES PRIMARY KEY(NRFREQGRPRATMES, NRORG)
)
/
ALTER TABLE FREQGRPRATMES ADD CONSTRAINT FKPLA00938FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE FREQGRPRATMES ADD CONSTRAINT FKPLA00939SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE FREQGRPRATMES ADD CONSTRAINT CKC_IDATIVO_FREQGRPRATMES CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX FKPLA00938FILIAL ON FREQGRPRATMES (CDFILIAL, NRORG)
/
CREATE INDEX FKPLA00939SERVICO ON FREQGRPRATMES (CDFILIAL, CDSERVFILI, NRORG)