Insert Unique Records in Vertica with COPY query -
i new vertica db, worked mysql previously. wanted insert unique records in vertica table, vertica doesn't support unique constraints while insertion. inserting records in table copy query. can't check each records before insertion, exist or not. can 1 me optimized way unique insertion.
thanks in advance:)
you can add no commit
copy
, run analyze_constraints
before commit
:
dbadmin=> create table tbl (a int primary key); create table dbadmin=> copy tbl stdin no commit; enter data copied followed newline. end backslash , period on line itself. >> 1 >> 2 >> 2 >> 3 >> \. dbadmin=> select * tbl; --- 1 2 2 3 (4 rows) dbadmin=> select analyze_constraints('tbl'); schema name | table name | column names | constraint name | constraint type | column values -------------+------------+--------------+-----------------+-----------------+--------------- public | tbl | | c_primary | primary | ('2') (1 row) dbadmin=> delete tbl = 2; output -------- 2 (1 row) dbadmin=> commit; commit dbadmin=> select * tbl; --- 1 3 (2 rows)
this simplistic example.
i've covered topic on blog post, enforcing uniqueness of data on load.
update: of 7.2, vertica can automatically enforce primary , unique constraints on load.
Comments
Post a Comment