Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Alter table to create IDENTITY

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.

Comments

  •  

      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

     

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.