-- ============================================================
--   Table: VOOTRECHODATADIA
-- ============================================================
CREATE TABLE VOOTRECHODATADIA	
(
	CDFILIAL 				VARCHAR2(4) 					NOT NULL,
	CDCIA 					VARCHAR2(4) 					NOT NULL,
	NRVOO 					VARCHAR2(5) 					NOT NULL,
	CDTRECHO 				VARCHAR2(4) 					NOT NULL,
	NRSEQVOOTRECHODATA	NUMBER 							NOT NULL,
	DTDIA 					DATE 								NOT NULL,
	NRORG                NUMBER         DEFAULT 1 	NOT NULL,
	IDATIVO              VARCHAR2(1)    DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_VOOTRECHODATADIA 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_VOOTRECHODATADIA PRIMARY KEY (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRSEQVOOTRECHODATA, DTDIA)
)
/

ALTER TABLE VOOTRECHODATADIA ADD
    CONSTRAINT FKATE00218VOOTRECHODATA FOREIGN KEY  (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRSEQVOOTRECHODATA)
       REFERENCES VOOTRECHODATA (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRSEQVOOTRECHODATA)
/

CREATE INDEX FKATE00218VOOTRECHODATA ON VOOTRECHODATADIA (CDFILIAL, CDCIA, NRVOO, CDTRECHO, NRSEQVOOTRECHODATA)
/