How to generate a GUID in Oracle?

前端 未结 9 589
悲哀的现实
悲哀的现实 2020-12-04 10:49

Is it possible to auto-generate a GUID into an Insert statement?

Also, what type of field should I use to store this GUID?

9条回答
  •  伪装坚强ぢ
    2020-12-04 11:28

    It is not clear what you mean by auto-generate a guid into an insert statement but at a guess, I think you are trying to do something like the following:

    INSERT INTO MY_TAB (ID, NAME) VALUES (SYS_GUID(), 'Adams');
    INSERT INTO MY_TAB (ID, NAME) VALUES (SYS_GUID(), 'Baker');
    

    In that case I believe the ID column should be declared as RAW(16);

    I am doing this off the top of my head. I don't have an Oracle instance handy to test against, but I think that is what you want.

提交回复
热议问题