CREATE TABLE TIPONOTIFAPP
(
   CDTIPONOTIFICAAPP       	VARCHAR2(3)            	NOT NULL, 
   DSTIPONOTIFICAAPP       	VARCHAR2(100)          	NOT NULL,
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_TIPONOTIFAPP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   		NULL,
   DTULTATU                 	DATE                  		NULL,
   NRORGINCLUSAO      	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  		DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 			DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12) 		DEFAULT '1',
	CONSTRAINT PK_TIPONOTIFAPP PRIMARY KEY (CDTIPONOTIFICAAPP)
)
/
INSERT INTO TIPONOTIFAPP (CDTIPONOTIFICAAPP, DSTIPONOTIFICAAPP) VALUES ('001', 'CONSUMO')
/
INSERT INTO TIPONOTIFAPP (CDTIPONOTIFICAAPP, DSTIPONOTIFICAAPP) VALUES ('002', 'SALDO BAIXO')
/
INSERT INTO TIPONOTIFAPP (CDTIPONOTIFICAAPP, DSTIPONOTIFICAAPP) VALUES ('003', 'ERRO RECARGA')
/
INSERT INTO TIPONOTIFAPP (CDTIPONOTIFICAAPP, DSTIPONOTIFICAAPP) VALUES ('004', 'RECARGA FORA DO APP')
/
CREATE TABLE NOTIFICACAOAPP
(
   NRNOTIFICAAPP            	VARCHAR2(10)           	NOT NULL,
   CDCLIENTENOTIFAPP        	VARCHAR2(21)           	NOT NULL,
   CDCONSUMINOTIFAPP        VARCHAR2(21)           	NOT NULL,
   CDTIPONOTIFICAAPP        	VARCHAR2(3)            	NOT NULL,
   DSNOTIFICAAPP           	VARCHAR2(300)          	NOT NULL,
   DTNOTIFICAAPP            	DATE                   		NOT NULL,
   IDNOTIFICAAPPLIDA        	VARCHAR2(1)            	DEFAULT 'N' NOT NULL,
	CONSTRAINT CKC_IDNOTIFICAAPPLIDA CHECK (IDNOTIFICAAPPLIDA IN ('S','N')),
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_NOTIFICACAOAPP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   		NULL,
   DTULTATU                 	DATE                  		NULL,
   NRORGINCLUSAO      	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  		DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 			DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12) 		DEFAULT '1',
	CONSTRAINT PK_NOTIFICACAOAPP PRIMARY KEY (NRNOTIFICAAPP)
)
/
CREATE INDEX FK_VND00747 ON NOTIFICACAOAPP (CDTIPONOTIFICAAPP ASC)
/
ALTER TABLE NOTIFICACAOAPP
	ADD CONSTRAINT FKVND00747NOTIFICACAOAPP FOREIGN KEY (CDTIPONOTIFICAAPP)
      		REFERENCES TIPONOTIFAPP (CDTIPONOTIFICAAPP)
/
CREATE TABLE LOGNOTIFICAAPP
(
    NRLOGNOTIFAPP            	VARCHAR2(10)           	NOT NULL,
    DSLOGNOTIFAPP            	VARCHAR2(1000)          	NOT NULL,
    DTLOGNOTIFAPP            	DATE                   		NOT NULL,
    IDCONCLNOTAPP            	VARCHAR2(1)            	NOT NULL,
	CONSTRAINT CKC_IDCONCLNOTAPP CHECK (IDCONCLNOTAPP IN ('S','N')),
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_LOGNOTIFICAAPP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   		NULL,
   DTULTATU                 	DATE                  		NULL,
   NRORGINCLUSAO      	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  		DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 			DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12) 		DEFAULT '1',
    CONSTRAINT PK_NRLOGNOTIFAPP PRIMARY KEY (NRLOGNOTIFAPP)
)