CREATE TABLE FILIFORN (
  CDFORNECED      		VARCHAR2(21) 	NOT NULL,
  CDFILIAL        		VARCHAR2(4)  	NOT NULL,
  NRTELEFORNFIL   		VARCHAR2(25),
  NRRAMALFORNFIL  	VARCHAR2(25),
  NRRAMLFORNFIL1  	VARCHAR2(25),
  NRFAXFORNFIL    		VARCHAR2(25),
  NMCONTFORNFIL   	VARCHAR2(30),
  NRTELRESIFORFIL 		VARCHAR2(25),
  NRCELULARFORFIL 	VARCHAR2(25),
  DSEMAILFORNFIL  	VARCHAR2(40),
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_FILIFORN  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',
	CONSTRAINTS PK_FILIFORN PRIMARY KEY (CDFORNECED, CDFILIAL)
)
/
CREATE INDEX FIS00748_FK ON  FILIFORN (CDFILIAL ASC)
/
ALTER TABLE FILIFORN ADD
	CONSTRAINT FKFIS00748FILIAL FOREIGN KEY (CDFILIAL)
		REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FIS00749_FK ON  FILIFORN (CDFORNECED ASC)
/
ALTER TABLE FILIFORN ADD
	CONSTRAINT FKFIS00749FORNECEDORS  FOREIGN KEY (CDFORNECED)
		REFERENCES FORNECEDOR (CDFORNECED)
/
ALTER TABLE FORNECEDOR ADD IDTPFORN VARCHAR2(1) DEFAULT 'G'
	CONSTRAINT CKC_IDTPFORN_FORNECEDOR CHECK (IDTPFORN IN ('G','L'))