CREATE TABLE ENDECONS (
   CDCLIENTE      VARCHAR2(21) 		NOT NULL,
   CDCONSUMIDOR   VARCHAR2(21) 		NOT NULL,
   CDENDECONS     VARCHAR2(2) 		NOT NULL,
   DSENDECONS 	  VARCHAR2(100) 	NOT NULL,
   NRENDECONS 	  VARCHAR2(10)  	NULL,	
   NRCEPCONS      VARCHAR2(15) 		NULL,
   CDPAIS         VARCHAR2(4) 		NOT NULL,
   SGESTADO       VARCHAR2(2) 		NOT NULL,
   CDMUNICIPIO    VARCHAR2(4) 		NOT NULL,
   CDBAIRRO       VARCHAR2(10) 		NOT NULL,
   DSCOMPLENDECONS VARCHAR2(100)  	NULL,
   DSREFERENDECONS VARCHAR2(2000) 	NULL,
   NMQUADRANTECONS VARCHAR2(20) 	NULL,
   IDATUENDECONS  VARCHAR2(1) 		DEFAULT 'N' NOT NULL,
   NRORG          NUMBER        	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1)   	DEFAULT 'S' NOT NULL,	
   DTINCLUSAO     DATE          	DEFAULT SYSDATE,
   DTULTATU       DATE          	DEFAULT SYSDATE,
   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' NULL,
		CONSTRAINT CKC_IDATIVO_ENDECONS CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT CKC_IDATUENDECONS_ENDECONS CHECK (IDATUENDECONS IN ('S','N')),
		CONSTRAINT PK_ENDECONS PRIMARY KEY (CDCLIENTE,CDCONSUMIDOR,CDENDECONS)
)
/

CREATE INDEX VND00833_FK ON ENDECONS (CDCLIENTE ASC, CDCONSUMIDOR ASC)
/

ALTER TABLE ENDECONS
   ADD CONSTRAINT FKVND00833ENDECONS FOREIGN KEY (CDCLIENTE, CDCONSUMIDOR)
      REFERENCES CONSUMIDOR (CDCLIENTE, CDCONSUMIDOR)
/