I am going to create some table at Vertica Database on which i have to give Global Unique Identifier to identify each row uniquely. Please suggest how to do it?
Globally Unique Identifier in Vertica
1.1k views Asked by San At
2
There are 2 answers
2
On
Please refer to the documentation:
Types of Incrementing Value Objects
- Named sequences are database objects that generate unique numbers in ascending or descending sequential order. They are most often used when an application requires a unique identifier in a table or an expression. Once a named sequence returns a value, it never returns that same value again. Named sequences are independent objects, and while you can use their values in tables, they are not subordinate to them.
- Auto-increment column value: a sequence available only for numeric column types. Auto-increment sequences automatically assign the next incremental sequence value for that column when a new row is added to the table.
- Identity column: a sequence available only for numeric column types.
A named sequence is what you are looking for. You can use the same sequence for multiple tables:
Then
NEXTVAL('named_sequence')
, here used during table creation, is the equivalent ofNEWID()
you are looking for.