CREATE TABLE FREQPRATMES (
  NRFREQPRATMES NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  DTVIGENCIA DATE NOT NULL, 
  DSFREQPRATMES 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_FREQPRATMES PRIMARY KEY(NRFREQPRATMES, NRORG)
)
/
ALTER TABLE FREQPRATMES ADD CONSTRAINT FKPLA00946FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE FREQPRATMES ADD CONSTRAINT FKPLA00947SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE FREQPRATMES ADD CONSTRAINT CKC_IDATIVO_FREQPRATMES CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX FKPLA00946FILIAL ON FREQPRATMES (CDFILIAL, NRORG)
/
CREATE INDEX FKPLA00947SERVICO ON FREQPRATMES (CDFILIAL, CDSERVFILI, NRORG)