CREATE TABLE CARTDIGIT(
	CDCARTDIGIT 	VARCHAR2(4),
	NMCARTDIGIT 	VARCHAR2(50),
	CDINTEGRACAO 	VARCHAR2(20),
    NRORG 			NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 		VARCHAR2(1) DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_CARTDIGIT 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' NULL,
		CONSTRAINT PK_CARTDIGIT PRIMARY KEY (CDCARTDIGIT)
)
/

ALTER TABLE TIPORECE ADD CDCARTDIGIT VARCHAR2(4)
/

CREATE INDEX VND00804_FK ON TIPORECE (CDCARTDIGIT ASC)
/

ALTER TABLE TIPORECE ADD CONSTRAINT FKVND00804CARTDIG_TPRECE 
	FOREIGN KEY(CDCARTDIGIT) REFERENCES CARTDIGIT(CDCARTDIGIT)
/ 