Quaternion
Quaternion

Reputation: 10458

GUID as PK for DB2-400

I have a table that does not have a PK and I need to add one.

I was just going to add an an auto incrementing int as the last column (the database is not fully SQL so where I add the column actually matters).

I've heard talk of UID's a function that returns a unique identifier every time it is called so no two rows in any table that uses a UID would have the same unique identifier.

Does DB2400 (the DB2 on an AS400 or iSeries) have such a function?

Upvotes: 0

Views: 1990

Answers (2)

Paul Morgan
Paul Morgan

Reputation: 32538

You could use the ROW_ID data type or use the AS IDENTITY clause along with the GENERATE clause on both to create UIDs.

Upvotes: 0

Ian Bjorhovde
Ian Bjorhovde

Reputation: 11042

You don't say what version of iSeries software you are running, but newer releases of the OS (> 6.1) include the GENERATE_UNIQUE function for DB2.

Upvotes: 2

Related Questions