create foreign key only if it doesn't exits
Hello ,
is there any way to achieve the following in vertica?
alter table add constraint fk_table IF NOT EXISTS foreign key (col) references ....;
is there any way to achieve the following in vertica?
alter table add constraint fk_table IF NOT EXISTS foreign key (col) references ....;
0
Comments
\set fk_sql 'vsql -t -c "SELECT decode(count(*),0,'alter table temp2 ADD CONSTRAINT FK_TEMP2 FOREIGN KEY (ID) REFERENCES TEMP1(ID)',null) as Cnt FROM v_catalog.constraint_columns where table_name='temp2' and constraint_name='temp_fk' ;"'
--- execute the sql stored in variable
:fk_sql;