ALTER TABLE CRM_PARAMETRIZACAO MODIFY OPERDIFEVOL VARCHAR2(1) DEFAULT 'S' NOT NULL
/
-- ===============================================================
-- Table: CRM_CONCORRPROSPECT
-- Descrição: Cria tabela para relacionar concorrente e prospect
-- ===============================================================
CREATE TABLE CRM_CONCORRPROSPECT (
  NRCONCORRPROSPECT  NUMBER          NOT NULL,
  CDPROSPECT         VARCHAR2(21)    NOT NULL,
  NRCONCORRENTE      NUMBER          NOT NULL,
  DTINIVIGENCIA      DATE,
  DTFIMVIGENCIA      DATE,
  NRORG              NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_CRM_CONCORPROSP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO        DATE                  			NULL,
   DTULTATU          DATE                  			NULL,
   NRORGINCLUSAO     NUMBER          DEFAULT 1 			NULL,
   CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
   NRORGULTATU       NUMBER          DEFAULT 1 			NULL,
   CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE CRM_CONCORRPROSPECT ADD CONSTRAINT PK_CRM_CONCORRPROSPECT PRIMARY KEY (NRCONCORRPROSPECT)
/
ALTER TABLE CRM_CONCORRPROSPECT ADD CONSTRAINT FKCRM00089CONCORPROSP_PROSP FOREIGN KEY (CDPROSPECT) REFERENCES PROSPECT(CDPROSPECT)
/
CREATE INDEX CRM00089_FK ON CRM_CONCORRPROSPECT (CDPROSPECT ASC)
/
ALTER TABLE CRM_CONCORRPROSPECT ADD CONSTRAINT FKCRM00090CONCORPROSP_CONCOR FOREIGN KEY (NRCONCORRENTE) REFERENCES CRM_CONCORRENTE(NRCONCORRENTE)
/
CREATE INDEX CRM00090_FK ON CRM_CONCORRPROSPECT (NRCONCORRENTE ASC)
/
-- =========================================
-- TABLE: CRM_PARAMETRIZACAO 
-- =========================================
ALTER TABLE CRM_PARAMETRIZACAO ADD CONSTRAINT CKC_IDATIVO_OPERDIFEVOL CHECK (OPERDIFEVOL IN ('S', 'N'))