开发者

GUID as PK for DB2-400

开发者 https://www.devze.com 2023-01-30 09:14 出处:网络
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

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 i开发者_开发问答n 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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号