CREATE TABLE PROGRAMACAOPESQ (
  NRPROGRAMACAOPESQ NUMBER(10) NOT NULL, 
  NRLOCAL NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) DEFAULT NULL NULL, 
  HRINICIO VARCHAR2(4) NOT NULL, 
  HRFIM VARCHAR2(4) NOT NULL, 
  DTINICIO DATE NOT NULL, 
  DTFIM DATE NOT NULL, 
  NRQUESTIONARIO NUMBER(10) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 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, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_PROGRAMACAOPESQ PRIMARY KEY(NRPROGRAMACAOPESQ, NRORG)
)
/
ALTER TABLE PROGRAMACAOPESQ ADD CONSTRAINT FKMYM00633LOCAL FOREIGN KEY (NRLOCAL, NRORG) REFERENCES LOCAL (NRLOCAL, NRORG)
/
ALTER TABLE PROGRAMACAOPESQ ADD CONSTRAINT FKMYM00634FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE PROGRAMACAOPESQ ADD CONSTRAINT FKMYM00635SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE PROGRAMACAOPESQ ADD CONSTRAINT CKC_IDATIVO_PROGRAMACAOPESQ CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX MYM00633_FK ON PROGRAMACAOPESQ (NRLOCAL, NRORG)
/
CREATE INDEX MYM00634_FK ON PROGRAMACAOPESQ (CDFILIAL, NRORG)
/
CREATE INDEX MYM00635_FK ON PROGRAMACAOPESQ (CDFILIAL, CDSERVFILI, NRORG)