如何在 sql 文件中导出顶点表数据



我想在vertica中导出表数据并生成一个SQL INSERT脚本。我导出了表架构并生成了一个 SQL 脚本。有没有办法在顶点中导出表数据?

谢谢。

您可以做的是编写一个 vsql 脚本,将其输出到文件中。

脚本经验.sql:

-- don't align
a
-- tuples only
t
pset fieldsep '|'
-- write to workfile.sql
o workfile.sql
-- get the create table statement into the workfile
SELECT EXPORT_OBJECTS('','public.foo',FALSE);
-- put the COPY command for in-line data into the workfile
SELECT 'COPY public.foo FROM STDIN DELIMITER ''|'';';
-- export the table's data
SELECT * FROM public.foo;
-- append a backslash-dot line to mark the end of the input of the copy command.
SELECT '.'; 

生成的工作文件.sql:

CREATE TABLE public.foo
(
id numeric(37,15),
first_name varchar(256),
last_name varchar(256),
hire_dt timestamp
);

CREATE PROJECTION public.foo
(
id,
first_name,
last_name,
hire_dt
)
AS
SELECT foo.id,
foo.first_name,
foo.last_name,
foo.hire_dt
FROM public.foo
ORDER BY foo.id,
foo.first_name,
foo.last_name,
foo.hire_dt
UNSEGMENTED ALL NODES;
COPY public.foo FROM STDIN DELIMITER '|';
1.000000000000000|Arthur|Dent|2017-02-05 00:00:00
2.000000000000000|Ford|Prefect|2017-02-05 00:00:00
3.000000000000000|Zaphod|Beeblebrox|2017-02-05 00:00:00
4.000000000000000|Tricia|McMillan|2017-02-05 00:00:00
[ . . . ]
41.000000000000000|Lunkwill|Lunkwill|2017-02-05 00:00:00
42.000000000000000|Fook|Fook|2017-02-05 00:00:00
.

最新更新