CREATE TABLE VIGUTILPRATOSERV (
	NRVIGENCIA 		NUMBER 														NOT NULL,
	CDFILIAL 		VARCHAR2(4) 												NOT NULL,
	DTVIGENCIA 		DATE 														NOT NULL,
	DTVIGENCIAFIM 	DATE 														NULL,
	DESCRICAO 		VARCHAR2(250) 												NULL,
	IDTIPORESTRICAO	VARCHAR2(30)	DEFAULT 'CONTRATO' 							NOT NULL
		CONSTRAINT CKC_IDTIPORESTRICAO_VIGUTPSERV CHECK (IDTIPORESTRICAO IN ('PLANEJADO', 'CONTRATO')),
	NRORG 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 		VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_VIGUTILPRATOSERV 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_VIGUTILPRATOSERV PRIMARY KEY (NRVIGENCIA)
)
/
ALTER TABLE VIGUTILPRATOSERV ADD CONSTRAINT UN_VIGUTILPRATOSERV UNIQUE (CDFILIAL, DTVIGENCIA, DTVIGENCIAFIM)
/
ALTER TABLE VIGUTILPRATOSERV ADD
	CONSTRAINT FKPLA01151FILIAL FOREIGN KEY (CDFILIAL)
		REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKPLA01151FILIAL ON VIGUTILPRATOSERV (CDFILIAL)