CREATE TABLE CARGOVENDASOPERADOR
(
    CDCARGO        	VARCHAR2(3)  	NOT NULL,
    CDOPERADOR     	VARCHAR2(12)	NOT NULL,
    NRORG 	       	NUMBER 		DEFAULT 	SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO		VARCHAR2(1)	DEFAULT 'S' 	NOT NULL,
	CONSTRAINT CKC_IDATIVO_CARGOVENDASOPER 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'	NULL,    
	CONSTRAINT PK_CARGOVEN PRIMARY KEY (CDCARGO, CDOPERADOR)
)
/
CREATE TABLE CARGOVENDASFILIAL
(
    CDCARGO        	VARCHAR2(3) 	NOT NULL,
    CDFILIAL       	VARCHAR2(4) 	NOT NULL,
    CDOPERADOR     	VARCHAR2(12) 	NOT NULL,
    NRORG 	   	NUMBER 		DEFAULT 	SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO	   	VARCHAR2(1)	DEFAULT 'S' 	NOT NULL,
		CONSTRAINT CKC_IDATIVO_CARGOVENDASFILI 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'	NULL,    
		CONSTRAINT PK_CARGOVENDASFILIAL PRIMARY KEY (CDCARGO, CDOPERADOR, CDFILIAL)
)
/
CREATE TABLE TIPOLOJA
(
	CDTIPOLOJA     		VARCHAR2(20),
    	NMTIPOLOJA     		VARCHAR2(40),
	NRORG 	       		NUMBER 		DEFAULT 	SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO	       		VARCHAR2(1)	DEFAULT 'S' 	NOT NULL,
		CONSTRAINT CKC_IDATIVO_TIPOLOJA 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'	NULL,    
		CONSTRAINT PK_TIPOLOJA PRIMARY KEY (CDTIPOLOJA)
)
/
CREATE TABLE FILILOJATIPO
(
	CDTIPOLOJA     		VARCHAR2(20),
    	CDLOJA         		VARCHAR2(10),
    	CDFILIAL       		VARCHAR2(4),
	NRORG 	       		NUMBER 		DEFAULT 	SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO			VARCHAR2(1)	DEFAULT 'S' 	NOT NULL,
		CONSTRAINT CKC_IDATIVO_FILILOJATIPO 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'		NULL,    
		CONSTRAINT PK_FILILOJATIPO PRIMARY KEY (CDFILIAL, CDLOJA)
)