CREATE TABLE RESPOSTAPESQ (
  NRRESPOSTAPESQ NUMBER(10) NOT NULL, 
  NRLOCALPESQ NUMBER(10) DEFAULT NULL NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  NRQUESTAO NUMBER(10) NOT NULL, 
  TXRESPOSTAPESQ VARCHAR2(4000) DEFAULT NULL NULL, 
  NRRESPOSTA NUMBER(10) DEFAULT NULL NULL, 
  NRUSUARIOPESQ NUMBER(10) DEFAULT NULL NULL, 
  IDAPLICATIVO VARCHAR2(30) 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
)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT CKC_IDAPLICATIVO_RESPOSTAPESQ CHECK (IDAPLICATIVO IN ('MYMENU','MYQUEST'))
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT CKC_IDATIVO_RESPOSTAPESQ CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT PK_RESPOSTAPESQ PRIMARY KEY(NRRESPOSTAPESQ, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00629LOCALPESQ FOREIGN KEY(NRLOCALPESQ, NRORG) REFERENCES LOCALPESQ (NRLOCALPESQ, NRORG)
/
CREATE INDEX MYM00629_FK ON RESPOSTAPESQ (NRLOCALPESQ, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00630FILIAL FOREIGN KEY(CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
CREATE INDEX MYM00630_FK ON RESPOSTAPESQ (CDFILIAL, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00631QUESTAO FOREIGN KEY(NRQUESTAO, NRORG) REFERENCES QUESTAO (NRQUESTAO, NRORG)
/
CREATE INDEX MYM00631_FK ON RESPOSTAPESQ (NRQUESTAO, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00632QUESTIONARIO FOREIGN KEY(NRQUESTIONARIO, NRORG) REFERENCES QUESTIONARIO (NRQUESTIONARIO, NRORG)
/
CREATE INDEX MYM00632_FK ON RESPOSTAPESQ (NRQUESTIONARIO, NRORG)