CREATE TABLE MIDIATAA(
	CDFILIAL VARCHAR2(4),
	CDCAIXA VARCHAR2(3),
	TPMIDIATAA VARCHAR2(1),
	LAYOUTMIDIA VARCHAR2(1),
	TMPDURACAO VARCHAR2(5),
	CDPRODUTO VARCHAR2(10),
	MIDIAURLTAA VARCHAR2(200),
	NRORG 			NUMBER 			DEFAULT SYS_CONTEXT('NRORG_CTX','NRORG') NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_MIDIATAA 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'
)
/

ALTER TABLE MIDIATAA ADD CONSTRAINT CKC_MIDIATAA_TPMIDIATAA CHECK (TPMIDIATAA IN ('I', 'V', 'G'))
/


ALTER TABLE MIDIATAA ADD CONSTRAINT CKC_MIDIATAA_LAYOUTMIDIA CHECK (LAYOUTMIDIA IN ('I', 'C', 'F'))
/

CREATE INDEX VND00789_FK ON MIDIATAA (CDFILIAL ASC)
/

ALTER TABLE MIDIATAA ADD CONSTRAINT FKVND00789FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/

CREATE INDEX VND00790_FK ON MIDIATAA (CDFILIAL ASC, CDCAIXA ASC)
/

ALTER TABLE MIDIATAA ADD CONSTRAINT FKVND00790CAIXA FOREIGN KEY (CDFILIAL,CDCAIXA) REFERENCES CAIXA (CDFILIAL,CDCAIXA)
/
