CREATE TABLE RESPOSTAPESQ (
  NRRESPOSTAPESQ NUMBER(10) NOT NULL, 
  NRLOCAL NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  NRQUESTAO NUMBER(10) NOT NULL, 
  TEXTORESPOSTA VARCHAR2(4000) DEFAULT NULL NULL, 
  NRRESPOSTA NUMBER(10) DEFAULT NULL NULL, 
  NRUSUARIO VARCHAR2(12) DEFAULT NULL NULL, 
  NMAPLICATIVO VARCHAR2(40) NOT NULL, 
  NRQUESTIONARIO NUMBER(10) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(12) DEFAULT '1' 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_RESPOSTAPESQ PRIMARY KEY(NRRESPOSTAPESQ, NRORG)
)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00629LOCAL FOREIGN KEY (NRLOCAL, NRORG) REFERENCES LOCAL (NRLOCAL, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00630FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00631QUESTAO FOREIGN KEY (NRQUESTAO, NRORG) REFERENCES QUESTAO (NRQUESTAO, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT FKMYM00632QUESTIONARIO FOREIGN KEY (NRQUESTIONARIO, NRORG) REFERENCES QUESTIONARIO (NRQUESTIONARIO, NRORG)
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT CKC_NMAPLICATIVO_RESPOSTAPESQ CHECK (NMAPLICATIVO IN ('MYMENU','MYQUEST'))
/
ALTER TABLE RESPOSTAPESQ ADD CONSTRAINT CKC_IDATIVO_RESPOSTAPESQ CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX MYM00629_FK ON RESPOSTAPESQ (NRLOCAL, NRORG)
/
CREATE INDEX MYM00630_FK ON RESPOSTAPESQ (CDFILIAL, NRORG)
/
CREATE INDEX MYM00631_FK ON RESPOSTAPESQ (NRQUESTAO, NRORG)
/
CREATE INDEX MYM00632_FK ON RESPOSTAPESQ (NRQUESTIONARIO, NRORG)