CREATE TABLE CRM_GAMENIVEL
(
    NRSEQNIVEL          	NUMBER                 		NOT NULL,
    NMNIVELANALISTA     	VARCHAR2(200)          	NOT NULL,
    QTPNTNIVEL          	NUMBER                 		NOT NULL,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GAMENVL CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMENIVEL_PK PRIMARY KEY (NRSEQNIVEL)
)
/
CREATE TABLE CRM_GAMEDISTINTIVO
(
    NRSEQDISTINTIVO     	NUMBER                 		NOT NULL,
    NMDISTINTIVO        	VARCHAR2(200)          	NOT NULL,
    DSDISTINTIVO       	VARCHAR2(2000)         	NULL    ,
    DSCAMINHOIMG        	CLOB                   		NOT NULL,
    IDTIPODISTINTIVO    	VARCHAR2(1)            	DEFAULT 'M' NOT NULL
        CONSTRAINT CKC_IDTPDIST_GAMEDIST CHECK (IDTIPODISTINTIVO IN ('M','T')),
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GAMEDIST CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEDISTINTIVO_PK PRIMARY KEY (NRSEQDISTINTIVO)
)
/
CREATE TABLE CRM_GAMEFICATION
(
    NRSEQGAME           	NUMBER                 		NOT NULL,
    NMGAMEFICATION      	VARCHAR2(500)          	NOT NULL,
    IDPADRAO            	VARCHAR2(1)            	DEFAULT 'N' NOT NULL
        CONSTRAINT CKC_IDPADRAO_GAMEFICAT CHECK (IDPADRAO IN ('S','N')),
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GAMEFICAT CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEFICATION_PK PRIMARY KEY (NRSEQGAME)
)
/
CREATE TABLE CRM_GAMEMETA
(
    NRSEQMETA           	NUMBER                 		NOT NULL,
    NMMETA              	VARCHAR2(500)          	NOT NULL,
    IDPADRAO            	VARCHAR2(1)            	DEFAULT 'N' NOT NULL
        CONSTRAINT CKC_IDPADRAO_GAMEMETA CHECK (IDPADRAO IN ('S','N')),
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                  		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GAMEMETA CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEMETA_PK PRIMARY KEY (NRSEQMETA)
)
/
CREATE TABLE CRM_GAMEMETASOLUCIONA
(
    NRSEQGAMEMETASOLU   	NUMBER                 		NOT NULL,
    NRSEQMETA           	NUMBER                 		NOT NULL,
    NMGAMEMETASOLU      	VARCHAR2(200)          	NOT NULL,
    DSGAMEMETASOLU      	VARCHAR2(2000)         	NOT NULL,
    QTTICKET            	NUMBER                 		NOT NULL,
    IDPERSOLUTICKET     	VARCHAR2(2)            	DEFAULT 'QT' NOT NULL
        CONSTRAINT CKC_IDPERSOLTIC_GMMETASOL CHECK (IDPERSOLUTICKET IN ('QT','1D','2D','3D','1S','2S','3S','1M','2M','3M','1A')),
    QTPNTBONUS          	NUMBER                 		NOT NULL,
    NRSEQDISTINTIVO     	NUMBER                		NOT NULL,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMMETASOL CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEMETASOLUCIONA_PK PRIMARY KEY (NRSEQGAMEMETASOLU)
)
/
CREATE INDEX CRM00061_FK ON CRM_GAMEMETASOLUCIONA (NRSEQMETA ASC)
/
CREATE INDEX CRM00062_FK ON CRM_GAMEMETASOLUCIONA (NRSEQDISTINTIVO ASC)
/
CREATE TABLE CRM_GAMEPONTUACAO
(
    NRSEQPONTUACAO      	NUMBER                 		NOT NULL,
    CDOPERADOR          	VARCHAR2(12)           	NOT NULL,
    NRSEQCONTATO        	NUMBER                 		NOT NULL,
    DSMOTIVOPONTO       	VARCHAR2(2)           	NOT NULL,
    IDMOTIVOPONTO       	VARCHAR2(3)            	NOT NULL
        CONSTRAINT CKC_IDMOTIVOPONTO_GMPNT CHECK (IDMOTIVOPONTO IN ('PCI','PCS','TFR','TFP','TFL','TFU','PRR','PRP','PRL','TFM','MTB')),
    QNTPONTO            	NUMBER                 		NOT NULL,
    NRSEQGAME           	NUMBER                 		NULL    ,
    NRSEQGAMEMETASOLU   	NUMBER                 		NULL    ,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMPNT CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEPONTUACAO_PK PRIMARY KEY (NRSEQPONTUACAO)
)
/
CREATE INDEX CRM00063_FK ON CRM_GAMEPONTUACAO (NRSEQCONTATO ASC)
/
CREATE INDEX CRM00064_FK ON CRM_GAMEPONTUACAO (NRSEQGAME ASC)
/
CREATE INDEX CRM00065_FK ON CRM_GAMEPONTUACAO (NRSEQGAMEMETASOLU ASC)
/
CREATE TABLE CRM_GAMECONDICAOSOLU
(
    NRSEQCONDGAME       	NUMBER                 		NOT NULL,
    IDCONDGAME          	VARCHAR2(2)            	DEFAULT 'E' NOT NULL
        CONSTRAINT CKC_IDCONDGAME_GMCOND CHECK (IDCONDGAME IN ('E','NE')),
    IDTPCONDGAME        	VARCHAR2(2)            	NOT NULL
        CONSTRAINT CKC_IDTPCONDGAME_GMCOND CHECK (IDTPCONDGAME IN ('PR','TI','OR','AC','SR','CL','MT','TG')),
    VRCONDGAME          	VARCHAR2(200)          	NOT NULL,
    NRSEQGAMEMETASOLU   	NUMBER                 		NOT NULL,
    TXCONDGAME          	VARCHAR2(500)          	NULL    ,
    NRORG               		NUMBER                		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMCOND CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMECONDICAOSOLU_PK PRIMARY KEY (NRSEQCONDGAME)
)
/
CREATE INDEX CRM00066_FK ON CRM_GAMECONDICAOSOLU (NRSEQGAMEMETASOLU ASC)
/
CREATE TABLE CRM_GAMEPNTRESPONDE
(
    NRSEQRESPONDE       	NUMBER                 		NOT NULL,
    QTPNTRAPIDO         	NUMBER                 		NOT NULL,
    QTPNTPRAZO          	NUMBER                 		NOT NULL,
    QTPNTLENTO          	NUMBER                		NOT NULL,
    NRSEQGAME           	NUMBER                 		NOT NULL,
    NRPRIORIDADE        	NUMBER                	 	NULL    ,
    NRORG               		NUMBER                		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMPNRESP CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEPNTRESPONDE_PK PRIMARY KEY (NRSEQRESPONDE)
)
/
CREATE INDEX CRM00067_FK ON CRM_GAMEPNTRESPONDE (NRSEQGAME ASC)
/
CREATE INDEX CRM00068_FK ON CRM_GAMEPNTRESPONDE (NRPRIORIDADE ASC)
/
CREATE TABLE CRM_GAMEPNTSOLUCIONA
(
    NRSEQSOLUCIONA      	NUMBER                 		NOT NULL,
    QTPNTRAPIDO        	NUMBER                 		NOT NULL,
    QTPNTPRAZO          	NUMBER                		NOT NULL,
    QTPNTLENTO          	NUMBER                 		NOT NULL,
    NRSEQGAME           	NUMBER                 		NOT NULL,
    NRPRIORIDADE        	NUMBER                		NULL    ,
    IDPONTOREABERTURA   	VARCHAR2(1)            	DEFAULT 'X' NOT NULL
        CONSTRAINT CKC_IDPTREAV_GMPNTSOL CHECK (IDPONTOREABERTURA IN ('X','T')),
    QTPNTREABERTURA     	NUMBER                 		NULL    ,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMPNTSOL CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEPNTSOLUCIONA_PK PRIMARY KEY (NRSEQSOLUCIONA)
)
/
CREATE INDEX CRM00069_FK ON CRM_GAMEPNTSOLUCIONA (NRSEQGAME ASC)
/
CREATE INDEX CRM00070_FK ON CRM_GAMEPNTSOLUCIONA (NRPRIORIDADE ASC)
/
CREATE TABLE CRM_GAMEPNTBONUS
(
    NRSEQBONUS          	NUMBER                 		NOT NULL,
    NRSEQGAME           	NUMBER                 		NOT NULL,
    QTPNTPRICHAMADA     	NUMBER                 		NOT NULL,
    QTPNTSATISFEITO     	NUMBER                 		NOT NULL,
    QTPNTINSATISFEITO   	NUMBER                 		NOT NULL,
    QTMAXRESPTICKET     	NUMBER                 		NOT NULL,
    QTPNTMAXRESPTICKET  	NUMBER                 		NOT NULL,
    NRPRIORIDADE        	NUMBER                 		NULL    ,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMPNTBON CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMEPNTBONUS_PK PRIMARY KEY (NRSEQBONUS)
)
/
CREATE INDEX CRM00071_FK ON CRM_GAMEPNTBONUS (NRSEQGAME ASC)
/
CREATE INDEX CRM00072_FK ON CRM_GAMEPNTBONUS (NRPRIORIDADE ASC)
/
CREATE TABLE CRM_GAMERESULTADO
(
    NRSEQGAMERESULTADO 	NUMBER                		NOT NULL,
    NRSEQDISTINTIVO     	NUMBER                 		NOT NULL,
    NRSEQPONTUACAO     	NUMBER                 		NULL    ,
    NRORG               		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO          	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU            	DATE                   		NULL    ,
    NRORGINCLUSAO       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU         	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU        	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO             		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_CRM_GMRESUL CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CRM_GAMERESULTADO_PK PRIMARY KEY (NRSEQGAMERESULTADO)
)
/
CREATE INDEX CRM00073_FK ON CRM_GAMERESULTADO (NRSEQDISTINTIVO ASC)
/
CREATE INDEX CRM00074_FK ON CRM_GAMERESULTADO (NRSEQPONTUACAO ASC)
/
ALTER TABLE CRM_GAMEMETASOLUCIONA
    ADD CONSTRAINT FKCRM00061GAMEMETA FOREIGN KEY  (NRSEQMETA)
       REFERENCES CRM_GAMEMETA (NRSEQMETA)
/
ALTER TABLE CRM_GAMEMETASOLUCIONA
    ADD CONSTRAINT FKCRM00062_GAMEDIST FOREIGN KEY  (NRSEQDISTINTIVO)
       REFERENCES CRM_GAMEDISTINTIVO (NRSEQDISTINTIVO)
/
ALTER TABLE CRM_GAMEPONTUACAO
    ADD CONSTRAINT FKCRM00063_CONTATO FOREIGN KEY  (NRSEQCONTATO)
       REFERENCES CONTATO (NRSEQCONTATO)
/
ALTER TABLE CRM_GAMEPONTUACAO
    ADD CONSTRAINT FKCRM00064_GAMEFICA FOREIGN KEY  (NRSEQGAME)
       REFERENCES CRM_GAMEFICATION (NRSEQGAME)
/
ALTER TABLE CRM_GAMEPONTUACAO
    ADD CONSTRAINT FKCRM00065_GAMEMETSOL FOREIGN KEY  (NRSEQGAMEMETASOLU)
       REFERENCES CRM_GAMEMETASOLUCIONA (NRSEQGAMEMETASOLU)
/
ALTER TABLE CRM_GAMECONDICAOSOLU
    ADD CONSTRAINT FKCRM00066_GAMEMETSOL FOREIGN KEY  (NRSEQGAMEMETASOLU)
       REFERENCES CRM_GAMEMETASOLUCIONA (NRSEQGAMEMETASOLU)
/
ALTER TABLE CRM_GAMEPNTRESPONDE
    ADD CONSTRAINT FKCRM00067_GAMEFICATION FOREIGN KEY  (NRSEQGAME)
       REFERENCES CRM_GAMEFICATION (NRSEQGAME)
/
ALTER TABLE CRM_GAMEPNTRESPONDE
    ADD CONSTRAINT FKCRM00068_PRIORIDADE FOREIGN KEY  (NRPRIORIDADE)
       REFERENCES CRM_PRIORIDADE (NRPRIORIDADE)
/
ALTER TABLE CRM_GAMEPNTSOLUCIONA
    ADD CONSTRAINT FKCRM00069_GAMEFICATION FOREIGN KEY  (NRSEQGAME)
       REFERENCES CRM_GAMEFICATION (NRSEQGAME)
/
ALTER TABLE CRM_GAMEPNTSOLUCIONA
    ADD CONSTRAINT FKCRM00070_PRIORIDADE FOREIGN KEY  (NRPRIORIDADE)
       REFERENCES CRM_PRIORIDADE (NRPRIORIDADE)
/
ALTER TABLE CRM_GAMEPNTBONUS
    ADD CONSTRAINT FKCRM00071_GAMEFICATION FOREIGN KEY  (NRSEQGAME)
       REFERENCES CRM_GAMEFICATION (NRSEQGAME)
/
ALTER TABLE CRM_GAMEPNTBONUS
    ADD CONSTRAINT FKCRM00072_PRIORIDADE FOREIGN KEY  (NRPRIORIDADE)
       REFERENCES CRM_PRIORIDADE (NRPRIORIDADE)
/
ALTER TABLE CRM_GAMERESULTADO
    ADD CONSTRAINT FKCRM00073_GAMEDIST FOREIGN KEY  (NRSEQDISTINTIVO)
       REFERENCES CRM_GAMEDISTINTIVO (NRSEQDISTINTIVO)
/
ALTER TABLE CRM_GAMERESULTADO
    ADD CONSTRAINT FKCRM00074_GAMEPONT FOREIGN KEY  (NRSEQPONTUACAO)
       REFERENCES CRM_GAMEPONTUACAO (NRSEQPONTUACAO)
/
CREATE TABLE CRM_SOLUCAOCATEGORIA
(
    NRSEQCATEGORIA     	NUMBER                 		NOT NULL,
    NMCATEGORIA        	VARCHAR2(500)          	NOT NULL,
    DSCATEGORIA        	VARCHAR2(2000)         	NULL    ,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO           		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLCATE CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUCAOCATE PRIMARY KEY (NRSEQCATEGORIA)
)
/
CREATE TABLE CRM_SOLUMOTRETARTIGO
(
    NRSEQRETMOTIVO     	NUMBER                 		NOT NULL,
    DSRETMOTIVO        	VARCHAR2(2000)        	NOT NULL,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLMOTRETART CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUMOTRETA PRIMARY KEY (NRSEQRETMOTIVO)
)
/
CREATE TABLE CRM_SOLUCAOPASTA
(
    NRSEQPASTA        	NUMBER                 		NOT NULL,
    NRSEQCATEGORIA     	NUMBER                 		NOT NULL,
    NMPASTA            		VARCHAR2(500)          	NOT NULL,
    DSPASTA            		VARCHAR2(2000)         	NULL    ,
    IDVISIBILIDADE     	VARCHAR2(15)           	DEFAULT 'TD_OPERADOR' NOT NULL
        CONSTRAINT CKC_IDVISIB_SOLPASTA CHECK (IDVISIBILIDADE IN ('TD_OPERADOR','TD_ANALISTA','TD_VISIANTE','SELEC_CLIENTE','SELEC_GRUPO')),
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)           	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLPASTA CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUCAOPAST PRIMARY KEY (NRSEQPASTA)
)
/
CREATE INDEX CRM00075_FK ON CRM_SOLUCAOPASTA (NRSEQCATEGORIA ASC)
/
CREATE TABLE CRM_SOLUCAOARTIGO
(
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    NRSEQPASTA         	NUMBER                 		NOT NULL,
    DSTITULOARTIGO     	VARCHAR2(200)          	NOT NULL,
    DSTXARTIGO         	CLOB                   		NOT NULL,
    IDTIPOARTIGO       	VARCHAR2(20)           	DEFAULT 'PERMANENTE' NOT NULL
        CONSTRAINT CKC_IDTPART_SOLART CHECK (IDTIPOARTIGO IN ('PERMANENTE','ALTERNATIVO')),
    DTHRDESPUBLICA     	DATE                   		NULL    ,
    CDOPERDESPUBLICA   	VARCHAR2(12)           	NULL    ,
    DTHRPUCLICA        	DATE                   		NULL    ,
    CDOPERPUBLICA      	VARCHAR2(12)           	NULL    ,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO           		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLART CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUCAOARTI PRIMARY KEY (NRSEQARTIGO)
)
/
CREATE INDEX CRM00076_FK ON CRM_SOLUCAOARTIGO (NRSEQPASTA ASC)
/
CREATE TABLE CRM_SOLUTAGARTIGO
(
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    IDNOMETAG          	NUMBER                 		NOT NULL,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                  		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLUTART CHECK (IDATIVO IN ('S','N')),
      CONSTRAINT PK_CRM_SOLUTAGARTI PRIMARY KEY (NRSEQARTIGO, IDNOMETAG)
)
/
CREATE INDEX CRM00077_FK ON CRM_SOLUTAGARTIGO (NRSEQARTIGO ASC)
/
CREATE INDEX CRM00078_FK ON CRM_SOLUTAGARTIGO (IDNOMETAG ASC)
/
CREATE UNIQUE INDEX UN_SOLUTAGARTIGO ON CRM_SOLUTAGARTIGO (IDNOMETAG ASC, NRSEQARTIGO ASC)
/
CREATE TABLE CRM_SOLUPARCNEGPASTA
(
    NRSEQPASTA        	NUMBER                 		NOT NULL,
    NRPARCNEGOCIO      	NUMBER                 		NOT NULL,
    NRORG              		NUMBER                		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO        	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLPARPAST CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUPARCNEG PRIMARY KEY (NRSEQPASTA, NRPARCNEGOCIO)
)
/
CREATE INDEX CRM00079_FK ON CRM_SOLUPARCNEGPASTA (NRSEQPASTA ASC)
/
CREATE TABLE CRM_SOLUVISUALIZAARTIGO
(
    NRSEQVISUALIZACAO  	NUMBER                 		NOT NULL,
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO        	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)        	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)        	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLVISART CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUVISUALI PRIMARY KEY (NRSEQVISUALIZACAO)
)
/
CREATE INDEX CRM00080_FK ON CRM_SOLUVISUALIZAARTIGO (NRSEQARTIGO ASC)
/
CREATE TABLE CRM_SOLUUTILIDADEARTIGO
(
    NRSEQUTILIDADE     	NUMBER                 		NOT NULL,
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    NRSEQRETMOTIVO     	NUMBER                 		NOT NULL,
    IDUTILIDADE        	VARCHAR2(3)            	NOT NULL
        CONSTRAINT CKC_IDUTIL_SOLUTILART CHECK (IDUTILIDADE IN ('SIM','NAO')),
    DSCOMENTARIO       	VARCHAR2(2000)         	NULL    ,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLUTILART CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUUTILIDA PRIMARY KEY (NRSEQUTILIDADE, NRSEQRETMOTIVO)
)
/
CREATE INDEX CRM00081_FK ON CRM_SOLUUTILIDADEARTIGO (NRSEQARTIGO ASC)
/
CREATE INDEX CRM00082_FK ON CRM_SOLUUTILIDADEARTIGO (NRSEQRETMOTIVO ASC)
/
CREATE TABLE CRM_SOLUARTIGOPUBLICADO
(
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    DSTITULOARTIGO     	VARCHAR2(200)          	NOT NULL,
    DSTXARTIGO         	CLOB                   		NOT NULL,
    DTHRPUCLICA        	DATE                   		NOT NULL,
    CDOPERPUBLICA      	VARCHAR2(12)           	NOT NULL,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NOT NULL,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLARTPUB CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUARTIGOP PRIMARY KEY (NRSEQARTIGO)
)
/
CREATE TABLE CRM_SOLUANEXOARTIGO
(
    NRSEQARTIGO        	NUMBER                 		NOT NULL,
    NRSEQANEXO         	NUMBER                 		NOT NULL,
    DSCAMINHOANEXO     	VARCHAR2(2000)         	NOT NULL,
    NMARQUIVO          	VARCHAR2(300)          	NOT NULL,
    DSTIPO            		VARCHAR2(50)           	NULL    ,
    VRTAMANHO         	FLOAT                  		NULL    ,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLANEART CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUANEXOAR PRIMARY KEY (NRSEQARTIGO, NRSEQANEXO)
)
/
CREATE INDEX CRM00083_FK ON CRM_SOLUANEXOARTIGO (NRSEQARTIGO ASC)
/
CREATE TABLE CRM_SOLUGRUPOPASTA
(
    NRSEQPASTA         	NUMBER                 		NOT NULL,
    NRFILAATENDIMENTO  	NUMBER                 		NOT NULL,
    NRORG              		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO         	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU           		DATE                   		NULL    ,
    NRORGINCLUSAO      	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO     	VARCHAR2(12)          	DEFAULT '1' NOT NULL,
    NRORGULTATU        	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU       	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO            		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_SOLGRPPASTA CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_SOLUGRUPOPA PRIMARY KEY (NRSEQPASTA, NRFILAATENDIMENTO)
)
/
CREATE INDEX CRM00084_FK ON CRM_SOLUGRUPOPASTA (NRSEQPASTA ASC)
/
CREATE INDEX CRM00085_FK ON CRM_SOLUGRUPOPASTA (NRFILAATENDIMENTO ASC)
/
ALTER TABLE CRM_SOLUCAOPASTA
    ADD CONSTRAINT FKCRM00075SOLUCAOCAT FOREIGN KEY  (NRSEQCATEGORIA)
       REFERENCES CRM_SOLUCAOCATEGORIA (NRSEQCATEGORIA)
/
ALTER TABLE CRM_SOLUCAOARTIGO
    ADD CONSTRAINT FKCRM00076_SOLPASTA FOREIGN KEY  (NRSEQPASTA)
       REFERENCES CRM_SOLUCAOPASTA (NRSEQPASTA)
/
ALTER TABLE CRM_SOLUTAGARTIGO
    ADD CONSTRAINT FKCRM00077_SOLARTIGO FOREIGN KEY  (NRSEQARTIGO)
       REFERENCES CRM_SOLUCAOARTIGO (NRSEQARTIGO)
/
ALTER TABLE CRM_SOLUTAGARTIGO
    ADD CONSTRAINT FKCRM00078_TAG FOREIGN KEY  (IDNOMETAG)
       REFERENCES CRM_TAG (IDNOMETAG)
/
ALTER TABLE CRM_SOLUPARCNEGPASTA
    ADD CONSTRAINT FKCRM00079_SOLUPASTA FOREIGN KEY  (NRSEQPASTA)
       REFERENCES CRM_SOLUCAOPASTA (NRSEQPASTA)
/
ALTER TABLE CRM_SOLUVISUALIZAARTIGO
    ADD CONSTRAINT FKCRM00080_SOLARTIGO FOREIGN KEY  (NRSEQARTIGO)
       REFERENCES CRM_SOLUCAOARTIGO (NRSEQARTIGO)
/
ALTER TABLE CRM_SOLUUTILIDADEARTIGO
    ADD CONSTRAINT FKCRM00081_SOLARTIGO FOREIGN KEY  (NRSEQARTIGO)
       REFERENCES CRM_SOLUCAOARTIGO (NRSEQARTIGO)
/
ALTER TABLE CRM_SOLUUTILIDADEARTIGO
    ADD CONSTRAINT FKCRM00082_SOLMOTART FOREIGN KEY  (NRSEQRETMOTIVO)
       REFERENCES CRM_SOLUMOTRETARTIGO (NRSEQRETMOTIVO)
/
ALTER TABLE CRM_SOLUANEXOARTIGO
    ADD CONSTRAINT FKCRM0083_SOLARTIGO FOREIGN KEY  (NRSEQARTIGO)
       REFERENCES CRM_SOLUCAOARTIGO (NRSEQARTIGO)
/
ALTER TABLE CRM_SOLUGRUPOPASTA
    ADD CONSTRAINT FKCRM00084SOLUCAOPASTA FOREIGN KEY  (NRSEQPASTA)
       REFERENCES CRM_SOLUCAOPASTA (NRSEQPASTA)
/
ALTER TABLE CRM_SOLUGRUPOPASTA
    ADD CONSTRAINT FKCRM00085_FILAATEND FOREIGN KEY  (NRFILAATENDIMENTO)
       REFERENCES CRM_FILATENDIMENTO (NRFILAATENDIMENTO)
/
ALTER TABLE CRM_SOLUARTIGOPUBLICADO
    ADD CONSTRAINT FKCRM00086_SOLARTIGO FOREIGN KEY  (NRSEQARTIGO)
       REFERENCES CRM_SOLUCAOARTIGO (NRSEQARTIGO)
/
CREATE TABLE CRM_AVISOPORTAL
(
    NRSEQAVISOPORTAL  	NUMBER                 		NOT NULL,
    NMAVISO           		VARCHAR2(200)          	NOT NULL,
    DSAVISO           		CLOB                   		NOT NULL,
    DTINICIO          		DATE                   		NULL    ,
    DTFIM             		DATE                   		NULL    ,
    NRORG            		NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO        	DATE                   		DEFAULT SYSDATE NOT NULL,
    DTULTATU          		DATE                   		NULL    ,
    NRORGINCLUSAO     	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERINCLUSAO    	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    NRORGULTATU       	NUMBER                 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    CDOPERULTATU      	VARCHAR2(12)           	DEFAULT '1' NOT NULL,
    IDATIVO           		VARCHAR2(1)            	DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_AVIPORTAL CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT PK_CRM_AVISOPORTAL PRIMARY KEY (NRSEQAVISOPORTAL)
)