ALTER TABLE PARAVEND ADD IDUTLFECHDIA VARCHAR2(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE PARAVEND ADD CONSTRAINT CKC_IDUTLFECHDIA_PARAVEND CHECK (IDUTLFECHDIA IN ('S', 'N'))
/
ALTER TABLE PARAVEND ADD HRFECHDIA VARCHAR2(4) DEFAULT '0800' NOT NULL
/
CREATE TABLE FECHAMENTODIA
(
   CDFILIAL 		VARCHAR2(4) 		NOT NULL,
   DTMOVDIA 		DATE			NOT NULL,
   DTHRFECHDIA 		DATE 			NULL,
   NRORG                 	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FECHAMENTODIA 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_FECHAMENTODIA PRIMARY KEY (CDFILIAL, DTMOVDIA)
)
/
CREATE INDEX VND00752_FK ON FECHAMENTODIA (CDFILIAL ASC)
/
ALTER TABLE FECHAMENTODIA
	ADD CONSTRAINT FKVND00752FILIAL FOREIGN KEY (CDFILIAL)
		REFERENCES FILIAL (CDFILIAL)
/