CREATE TABLE TIPORECEFILIAL 
   (	CDFILIAL VARCHAR2(4), 
	CDTIPORECE VARCHAR2(3), 
	VRTAXAADMFIL FLOAT(126), 
	CDFORMPGTO VARCHAR2(2), 
	NRDIASADMIFIL VARCHAR2(3), 
	CDREDUCONT VARCHAR2(3), 
	CDTPBAIXAREC VARCHAR2(2), 
	IDGERAFINFIL VARCHAR2(1) DEFAULT 'S', 
	DTINCLUSAO DATE DEFAULT SYSDATE, 
	DTULTATU DATE DEFAULT SYSDATE, 
	NRORGINCLUSAO NUMBER(10,0), 
	CDOPERINCLUSAO VARCHAR2(12), 
	NRORGULTATU NUMBER(10,0), 
	CDOPERULTATU VARCHAR2(12), 
	IDATIVO VARCHAR2(1) DEFAULT 'S', 
	IDCONSVRDEBCONS VARCHAR2(1) DEFAULT 'N', 
	IDGERABAIXAUTO VARCHAR2(1) DEFAULT 'S', 
	CDCLIENTE VARCHAR2(21), 
	CDTPCTRECEB VARCHAR2(6), 
	CDAJTXADMREC VARCHAR2(4), 
	CDTPAJUSANGRRED VARCHAR2(4), 
	CDTPAJUSANGRACR VARCHAR2(4), 
	NRORG NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'), 
	IDCONTAREPFOS VARCHAR2(1) DEFAULT 'N', 
	IDBAIXAAUTCNC VARCHAR2(1) DEFAULT 'N', 
	IDGERAFINCLI VARCHAR2(1) DEFAULT 'N', 
	IDBAIXAARQVENDCNCFIL VARCHAR2(1)
)
/
CREATE INDEX PK_TIPORECEFILIAL ON TIPORECEFILIAL (CDFILIAL, CDTIPORECE)
/
CREATE INDEX VND00352_FK ON TIPORECEFILIAL (CDFORMPGTO)
/
CREATE INDEX VND00417_FK ON TIPORECEFILIAL (CDREDUCONT)
/
CREATE INDEX VND00418_FK ON TIPORECEFILIAL (CDTPBAIXAREC)
/
CREATE INDEX FIS00655_FK ON TIPORECEFILIAL (CDCLIENTE)
/
CREATE INDEX FIS00656_FK ON TIPORECEFILIAL (CDTPCTRECEB)
/
CREATE INDEX FIS00657_FK ON TIPORECEFILIAL (CDAJTXADMREC)
/
CREATE INDEX FIS00658_FK ON TIPORECEFILIAL (CDTPAJUSANGRRED)
/
CREATE INDEX FIS00659_FK ON TIPORECEFILIAL (CDTPAJUSANGRACR)
/
CREATE INDEX TIPORECEFILIAL_FK1 ON TIPORECEFILIAL (NRORG, CDFILIAL)
/
CREATE INDEX TIPORECEFILIAL_FK2 ON TIPORECEFILIAL (NRORG, CDTIPORECE)
/
CREATE INDEX FIN00365_FK ON TIPORECEFILIAL (CDTIPORECE, NRORG)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_IDCONSVRDEB_TIPORECEFIL CHECK (IDCONSVRDEBCONS IN ('S', 'N'))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_IDGERAFINFIL CHECK (IDGERAFINFIL is null or (IDGERAFINFIL in ('S','N')))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_TIPORECEFIL_IDGERABAIXAUTO CHECK (IDGERABAIXAUTO IN ('S','N'))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_TIPORECEFIL_IDGERAFINCLI CHECK ((IDGERAFINCLI IN ('S', 'N')))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_TPRECEFILIAL_IDBAIXAAUTCNC CHECK (IDBAIXAAUTCNC IN ('S', 'N'))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT CKC_TPRECEFILIAL_IDCONTAREPFOS CHECK (IDCONTAREPFOS IN ('N', 'S'))
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT PK_TIPORECEFILIAL PRIMARY KEY (CDFILIAL, CDTIPORECE)
/
ALTER TABLE TIPORECEFILIAL MODIFY (CDFILIAL NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (CDTIPORECE NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (VRTAXAADMFIL NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDATIVO NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDCONSVRDEBCONS NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDGERABAIXAUTO NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDCONTAREPFOS NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDBAIXAAUTCNC NOT NULL )
/
ALTER TABLE TIPORECEFILIAL MODIFY (IDGERAFINCLI NOT NULL )
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIN00364FILIAL FOREIGN KEY (CDFILIAL)
	  REFERENCES FILIAL (CDFILIAL)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIN00365TIPORECE FOREIGN KEY (CDTIPORECE)
	  REFERENCES TIPORECE (CDTIPORECE)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIS00655CLIENTE FOREIGN KEY (CDCLIENTE)
	  REFERENCES CLIENTE (CDCLIENTE)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIS00656CLIENTE FOREIGN KEY (CDTPCTRECEB)
	  REFERENCES TIPOCTRECEBER (CDTPCTRECEB)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIS00657TIPOAJRECEBER FOREIGN KEY (CDAJTXADMREC)
	  REFERENCES TIPOAJRECEBER (CDAJUCTREC)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIS00658TIPOAJRECEBER FOREIGN KEY (CDTPAJUSANGRRED)
	  REFERENCES TIPOAJRECEBER (CDAJUCTREC)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKFIS00659TIPOAJRECEBER FOREIGN KEY (CDTPAJUSANGRACR)
	  REFERENCES TIPOAJRECEBER (CDAJUCTREC)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKVND00352FORMPGTO FOREIGN KEY (CDFORMPGTO)
	  REFERENCES FORMPGTO (CDFORMPGTO)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKVND00417CONTCORR FOREIGN KEY (CDREDUCONT)
	  REFERENCES CONTCORR (CDREDUCONT)
/
ALTER TABLE TIPORECEFILIAL ADD CONSTRAINT FKVND00418TIPOBAIXAREC FOREIGN KEY (CDTPBAIXAREC)
	  REFERENCES TIPOBAIXAREC (CDTPBAIXAREC)