I want to move some tables from PostgreSQL to Vertica, but having trouble with saving column's types as they were. After moving table to Vertica all my columns' types are VARCHAR
. To copy table from PostgreSQL I use
SET DATESTYLE TO 'ISO';
COPY (select * from table_name) TO '/tmp/file_name.csv' WITH CSV HEADER;
To copy table to Vertica I use:
SET DATESTYLE TO 'ISO';
CREATE FLEX TABLE M.TABLE_NAME();
COPY M.TABLE_NAME FROM '/tmp/file_name.csv' PARSER FDELIMITEDPARSER (delimiter=',');
SELECT COMPUTE_FLEXTABLE_KEYS('M.TABLE_NAME');
SELECT COMPUTE_FLEXTABLE_KEYS_AND_BUILD_VIEW('M.TABLE_NAME');
CREATE TABLE M.TABLE_NAME_NORMAL_TABLE AS SELECT * FROM M.TABLE_NAME_view;
What am I doing wrong?
Copyright Notice:Content Author:「feygin」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32696653/trouble-with-moving-data-from-postgresql-to-vertica