Skip to main content

Alter table to create IDENTITY

  • January 11, 2017
  • 1 reply
  • 8 views

DaveDB

Hello,

 

I am relatively new to Vertica so pardon if my question seems basic...

 

I loaded a Vertica table and I am trying to ALTER a column to IDENTITY.

 

I know you simply cannot turn the IDENTITY on/off in Vertica like SQL server, but my idea is to load the table first and then set the identity. Is this possible? Is this best practice? 

 

Thank you all in advance.

1 reply

Adrian_Oprea_1
Forum|alt.badge.img+1
  • Participating Frequently
  • January 12, 2017

 

  Try using sequences instead of auto_increment, the reason is that you can change the default value of the column(simulate auto increment OFF) and change it back after you have inserted your data(simulate auto increment ON).

  

 Every time you switch on of off just alter the sequence definition to your max value of the column you have the id on.

ALTER SEQUENCE seq1 RESTART WITH 'max(id)';

make sure you give it the int value, subquery won`t work