CREATE TABLE VALEPEDAGIO
(
	CDVIATURA VARCHAR2(04) NOT NULL,
	NRLANCTOMDFE VARCHAR2(10) NOT NULL,
	NRSEQVALEPED VARCHAR2(04) NOT NULL,
	NRINSFORNVALPED VARCHAR2(21) NOT NULL,
	NRINSRESPVALPED VARCHAR2(21) NULL,
	NRCOMPROVCOMPRA VARCHAR2(20) NULL,
	VRVALEPEDAGIO NUMBER NOT NULL,
	DSTIPOVALEPED VARCHAR2(02) NULL,
	DSCATCOMBVEIC VARCHAR2(02) NULL,
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_VALEPEDAGIO CHECK (IDATIVO IN ('S','N')),
    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',
		CONSTRAINT PK_VALEPEDAGIO PRIMARY KEY (CDVIATURA, NRLANCTOMDFE, NRSEQVALEPED)
)
/

CREATE INDEX FIS00852_FK ON VALEPEDAGIO (CDVIATURA ASC, NRLANCTOMDFE ASC)
/

ALTER TABLE VALEPEDAGIO ADD CONSTRAINT FKFIS00852VALEPEDAGIO_MDFE FOREIGN KEY (CDVIATURA, NRLANCTOMDFE)
	REFERENCES MDFE (CDVIATURA, NRLANCTOMDFE) ON DELETE CASCADE
/