CREATE TABLE IF NOT EXISTS vnd_divisao_entrega( filial_orc integer NOT NULL, orcamento integer NOT NULL, sequencia_item integer NOT NULL, sequencia_entrega integer NOT NULL, sequencia_alteracao integer NOT NULL, usuario integer NOT NULL, data_alteracao date NOT NULL, hora_alteracao time without time zone NOT NULL, quantidade_entrega numeric(18,6) NOT NULL, produto integer NOT NULL, cliente integer NOT NULL, endereco_entrega integer NOT NULL, data_previsao_entrega date NOT NULL, almoxarifado integer NOT NULL, tipo_entrega integer NOT NULL, CONSTRAINT pk_vnd_divisao_entrega PRIMARY KEY (filial_orc, orcamento, sequencia_item, sequencia_entrega, sequencia_alteracao), CONSTRAINT fk_dis_pedidos_distribuicao FOREIGN KEY (filial_orc, orcamento, sequencia_item, sequencia_entrega) REFERENCES dis_pedidos_distribuicao (filial_orc, orcamento, sequencia, sequencia_entrega) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_ctl_usuario FOREIGN KEY (filial_orc, usuario) REFERENCES ctl_usuario (usufilial, usucod) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_pro_produto FOREIGN KEY (filial_orc, produto) REFERENCES pro_produto (filial_pro, codigo) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_cli_cliente FOREIGN KEY (filial_orc, cliente) REFERENCES cli_cliente (filial, codigo) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_cli_endereco FOREIGN KEY (filial_orc, cliente, endereco_entrega) REFERENCES cli_endereco (filial, cliente, sequencia) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_bas_almoxarifado FOREIGN KEY (filial_orc, almoxarifado) REFERENCES bas_almoxarifado (filial, codigo) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_bas_tipo_entrega FOREIGN KEY (tipo_entrega) REFERENCES bas_tipo_entrega (codigo) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT );