CREATE TABLE IF NOT EXISTS public.vnd_faturamento_parcial_relac ( filial integer NOT NULL, orcamento integer NOT NULL, filial_relac integer NOT NULL, orcamento_relac integer NOT NULL, CONSTRAINT pk_vnd_faturamento_parcial PRIMARY KEY (filial, orcamento, filial_relac, orcamento_relac), CONSTRAINT fk_vnd_faturamento_parcial_relac_orcamento FOREIGN KEY (filial, orcamento) REFERENCES public.vnd_orcamento (filial_orc, orcamento) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT, CONSTRAINT fk_vnd_faturamento_parcial_relac_orcamento_relac FOREIGN KEY (filial_relac, orcamento_relac) REFERENCES public.vnd_orcamento (filial_orc, orcamento) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.vnd_faturamento_parcial_relac OWNER to postgres; COMMENT ON TABLE public.vnd_faturamento_parcial_relac IS 'Tabela para Relacionar o Pedido Principal com os Pedidos Gerados a Partir do Faturamento Parcial'; CREATE TABLE IF NOT EXISTS public.vnd_faturamento_parcial_item ( filial integer NOT NULL, orcamento integer NOT NULL, sequencia integer NOT NULL, produto integer NOT NULL, quantidade numeric(18, 6) NOT NULL, CONSTRAINT pk_vnd_faturamento_parcial_item PRIMARY KEY (filial, orcamento, sequencia), CONSTRAINT fk_vnd_vnd_faturamento_parcial_item FOREIGN KEY (filial, orcamento) REFERENCES public.vnd_orcamento (filial_orc, orcamento) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT ) TABLESPACE pg_default; ALTER TABLE IF EXISTS public.vnd_faturamento_parcial_item OWNER to postgres; COMMENT ON TABLE public.vnd_faturamento_parcial_item IS 'Tabela para Gravar os Itens do Pedido Principal ao Gerar o Faturamento Parcial';