CREATE TABLE QUESTIONARIO (
  NRQUESTIONARIO NUMBER(10) NOT NULL, 
  NRTIPOQUESTIONARIO NUMBER(10) NOT NULL, 
  IDAPLICATIVO VARCHAR2(30) NOT NULL, 
  NMQUESTIONARIO VARCHAR2(100) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) 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
)
/
ALTER TABLE QUESTIONARIO ADD CONSTRAINT CKC_IDAPLICATIVO_QUESTIONARIO CHECK (IDAPLICATIVO IN ('MYMENU','MYQUEST'))
/
ALTER TABLE QUESTIONARIO ADD CONSTRAINT CKC_IDATIVO_QUESTIONARIO CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE QUESTIONARIO ADD CONSTRAINT PK_QUESTIONARIO PRIMARY KEY (NRQUESTIONARIO, NRORG)
/
ALTER TABLE QUESTIONARIO ADD CONSTRAINT FKMYM00626TIPOQUESTIONARIO FOREIGN KEY (NRTIPOQUESTIONARIO, NRORG) REFERENCES TIPOQUESTIONARIO (NRTIPOQUESTIONARIO, NRORG)
/
CREATE INDEX MYM00626_FK ON QUESTIONARIO (NRTIPOQUESTIONARIO, NRORG)