CREATE TABLE PRODXFORNDF (
   IDENTRSAIDOP      VARCHAR2(01)    NOT NULL,
   CDTIPOOPER        VARCHAR2(02)    NOT NULL,
   CDFORNECED        VARCHAR2(21)    NOT NULL,
   CDPRODUTO         VARCHAR2(10)    NOT NULL,
   CDPAIS            VARCHAR2(04)    NOT NULL,
   SGESTADO          VARCHAR2(02)    NOT NULL,
   CDMUNICIPIO       VARCHAR2(05)    NOT NULL,
   IDUTILIZA         VARCHAR2(01)    DEFAULT 'S' NOT NULL,
   NRORG             NUMBER 	     DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
   IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
   DTINCLUSAO        DATE            DEFAULT SYSDATE,
   DTULTATU          DATE            DEFAULT SYSDATE,
   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 CKC_IDATIVO_PRODXFORNDF CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT CKC_IDUTILIZA_PRODXFORNDF CHECK (IDUTILIZA IN ('S', 'N')),
        CONSTRAINT PK_PRODXFORNDF PRIMARY KEY (IDENTRSAIDOP, CDTIPOOPER, CDFORNECED, CDPRODUTO, CDPAIS, SGESTADO, CDMUNICIPIO)
)
/

ALTER TABLE PRODXFORNDF
   ADD CONSTRAINT FKFIS00905TIPOOPERAC FOREIGN KEY (IDENTRSAIDOP, CDTIPOOPER)
      REFERENCES TIPOOPERAC (IDENTRSAIDOP, CDTIPOOPER)
/

CREATE INDEX FIS00905_FK ON PRODXFORNDF (IDENTRSAIDOP ASC, CDTIPOOPER ASC)
/

ALTER TABLE PRODXFORNDF
   ADD CONSTRAINT FKFIS00906FORNECEDOR FOREIGN KEY (CDFORNECED)
      REFERENCES FORNECEDOR (CDFORNECED)
/

CREATE INDEX FIS00906_FK ON PRODXFORNDF (CDFORNECED ASC)
/

ALTER TABLE PRODXFORNDF
   ADD CONSTRAINT FKFIS00907PRODUTO FOREIGN KEY (CDPRODUTO)
      REFERENCES PRODUTO (CDPRODUTO)
/

CREATE INDEX FIS00907_FK ON PRODXFORNDF (CDPRODUTO ASC)
/

ALTER TABLE PRODXFORNDF
   ADD CONSTRAINT FKFIS00908MUNICIPIO FOREIGN KEY (CDPAIS, SGESTADO, CDMUNICIPIO)
      REFERENCES MUNICIPIO (CDPAIS, SGESTADO, CDMUNICIPIO)
/

CREATE INDEX FIS00908_FK ON PRODXFORNDF (CDPAIS ASC, SGESTADO ASC, CDMUNICIPIO ASC)
/
