CREATE TABLE RAZAO
( 
NRSEQRAZAO 		NUMBER 			NOT NULL,
NRRAZAO 		NUMBER 			NOT NULL,
CDCONTCTBL 		VARCHAR2(20) 	NOT NULL,
IDVALOR 		VARCHAR2(01) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDVALOR_RAZAO CHECK (IDVALOR IN ('S','L')),
NRLANCCONT 		VARCHAR2(12) 	NULL ,
DSHISTLANC 		VARCHAR2(600) 	NULL ,
VRLANCAMENT 	FLOAT 			NULL ,
VRSALDATUAL 	FLOAT 			NULL ,
DTLANCCONT 		DATE 			NULL ,
NRORG           NUMBER 	     	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
IDATIVO 		VARCHAR2(1) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_RAZAO 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_RAZAO PRIMARY KEY (NRSEQRAZAO)
)
/

CREATE INDEX CTB00224_FK ON RAZAO (CDCONTCTBL ASC)
/

ALTER TABLE RAZAO
	ADD CONSTRAINT FKCTB00224CONTCTBL FOREIGN KEY (CDCONTCTBL)
		REFERENCES CONTCTBL(CDCONTCTBL)
/

ALTER TABLE RAZAO ADD IDPART VARCHAR2(1) DEFAULT NULL
	CONSTRAINT CKC_IDPART_RAZAO CHECK (IDPART IN ('S','C','P',NULL))
/

ALTER TABLE RAZAO ADD CDEMPRESA VARCHAR2(2) NULL
/

ALTER TABLE RAZAO ADD CDDOCUCONT VARCHAR2(20) NULL
/

ALTER TABLE RAZAO ADD CDCONTCTBLT VARCHAR2(20) NULL
/