Vertica copy on tables with identity columns
Posted: Mon Oct 10, 2016 4:34 am
i created two tables
CREATE TABLE TEST1
(
TEST1_ID identity(1) ,
CHART_TYPE_DESC varchar(100) NOT NULL,
CREATED_BY_ID varchar(50),
MODIFIED_BY_ID varchar(50)
);
CREATE TABLE TEST2
(
TEST2_ID int ,
CHART_TYPE_DESC varchar(100) NOT NULL,
CREATED_BY_ID varchar(50),
MODIFIED_BY_ID varchar(50)
);
When i insert into table TEST1 doesnt work
insert into table test1 values (1,'ABC','A','A');
however taking inputs from
https://community.dev.hpe.com/t5/Vertic ... d-p/221757
i added SELECT set_optimizer_directives('AllowIdentityInsert=True');
and the insert worked.
However when i tried with copy command it doesnt work and gives error
vsql -U dbadmin -w test -c "SELECT set_optimizer_directives('AllowIdentityInsert=True');COPY test3 FROM '/home/dbadmin/test.csv' delimiter E',' EXCEPTIONS '/home/dbadmin/exceptions';"
COPY: Input record 1 has been rejected (Too many columns found). Please see /home/dbadmin/test/v_test_node0001_catalog/CopyErrorLogs/test3-test.csv-copy-from-rejected-data, record 1 for the rejected record.
however when i insert into table test2 which doesnt have identity column copy command works.
Is there any way to ask copy to ignore identity column and allow insert?
CREATE TABLE TEST1
(
TEST1_ID identity(1) ,
CHART_TYPE_DESC varchar(100) NOT NULL,
CREATED_BY_ID varchar(50),
MODIFIED_BY_ID varchar(50)
);
CREATE TABLE TEST2
(
TEST2_ID int ,
CHART_TYPE_DESC varchar(100) NOT NULL,
CREATED_BY_ID varchar(50),
MODIFIED_BY_ID varchar(50)
);
When i insert into table TEST1 doesnt work
insert into table test1 values (1,'ABC','A','A');
however taking inputs from
https://community.dev.hpe.com/t5/Vertic ... d-p/221757
i added SELECT set_optimizer_directives('AllowIdentityInsert=True');
and the insert worked.
However when i tried with copy command it doesnt work and gives error
vsql -U dbadmin -w test -c "SELECT set_optimizer_directives('AllowIdentityInsert=True');COPY test3 FROM '/home/dbadmin/test.csv' delimiter E',' EXCEPTIONS '/home/dbadmin/exceptions';"
COPY: Input record 1 has been rejected (Too many columns found). Please see /home/dbadmin/test/v_test_node0001_catalog/CopyErrorLogs/test3-test.csv-copy-from-rejected-data, record 1 for the rejected record.
however when i insert into table test2 which doesnt have identity column copy command works.
Is there any way to ask copy to ignore identity column and allow insert?