CREATE SEQUENCE SEQ_LOGERROCOTA INCREMENT BY 1 START WITH 1
/

CREATE TABLE LOGERROCOTA
(
	NRLOGERROCOTA 	  NUMBER 			NOT NULL,
	CDFILIAL 		  VARCHAR2(4) 		NOT NULL,
	NRCOLEPRECO 	  VARCHAR2(10) 		NOT NULL,
	CDFORNECED 		  VARCHAR2(21) 		NOT NULL,
	CDREGIAO 		  VARCHAR2(3) 		NOT NULL,
	CDMARCA 		  VARCHAR2(5) 		NOT NULL,
	CDPRODUTO 		  VARCHAR2(10) 		NOT NULL,
	DSERRO 			  VARCHAR2(300) 	NOT NULL,
    NRORG             NUMBER 	    	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)   	DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_LOGERROCOTA  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_LOGERROCOTA PRIMARY KEY (NRLOGERROCOTA)
)
/

CREATE INDEX IDX_LOGERROCOTA_01 ON LOGERROCOTA (CDFILIAL, NRCOLEPRECO, CDFORNECED, CDREGIAO, CDMARCA, CDPRODUTO)
/

CREATE SEQUENCE SEQ_LOGDADOSFORNECOMMERCE INCREMENT BY 1 START WITH 1
/

CREATE TABLE LOGDADOSFORNECOMMERCE
(
	NRLOGDADOSFORNECOMMERCE NUMBER 		NOT NULL,
	CDFORNECED 		  VARCHAR2(21) 		NOT NULL,
	DTOPERACAO 		  DATE 				NOT NULL,
	IDOPERACAO 		  VARCHAR2(1) 		NOT NULL,
	CONSTRAINT CKC_LOGDADOSFORNECOMMERCE_IDOP CHECK (IDOPERACAO IN ('I', 'U', 'D')),
	NMUSUARIOECO 	  VARCHAR2(200) 	NULL,
	DSLOGINECO 		  VARCHAR2(200) 	NULL,
	IDACESSOCOT 	  VARCHAR2(1) 		NULL,
	IDACESSOAF 		  VARCHAR2(1) 		NULL,
	IDACESSOCR 		  VARCHAR2(1) 		NULL,
	IDACESSOUPLOAD 	  VARCHAR2(1) 		NULL,
	IDADMINISTRADOR   VARCHAR2(1) 		NULL,
	DSEMAILECO 		  VARCHAR2(250) 	NULL,
    NRORG             NUMBER 	     	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)     	DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_LOGDADOSFORNECOMM 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_LOGDADOSFORNECOMMERCE PRIMARY KEY (NRLOGDADOSFORNECOMMERCE)
)
/

CREATE INDEX IDX_LOGDADOSFORNECOMMERCE_01 ON LOGDADOSFORNECOMMERCE (CDFORNECED, DTOPERACAO, IDOPERACAO)
/