如何在Oracle中生成GUID? [英] How to generate a GUID in Oracle?
问题描述
是否可以将GUID自动生成为Insert语句?
Is it possible to auto-generate a GUID into an Insert statement?
我还应该使用哪种类型的字段来存储此GUID?
Also, what type of field should I use to store this GUID?
推荐答案
您可以使用SYS_GUID()函数在插入语句中生成GUID:
You can use the SYS_GUID() function to generate a GUID in your insert statement:
insert into mytable (guid_col, data) values (sys_guid(), 'xxx');
用于存储GUID的首选数据类型是RAW(16).
The preferred datatype for storing GUIDs is RAW(16).
作为Gopinath的答案:
As Gopinath answer:
select sys_guid() from dual
union all
select sys_guid() from dual
union all
select sys_guid() from dual
你得到
88FDC68C75DDF955E040449808B55601
88FDC68C75DEF955E040449808B55601
88FDC68C75DFF955E040449808B55601
88FDC68C75DDF955E040449808B55601
88FDC68C75DEF955E040449808B55601
88FDC68C75DFF955E040449808B55601
正如托尼·安德鲁斯(Tony Andrews)所说, 仅在一个字符处不同
As Tony Andrews says, differs only at one character
88FDC68C75D D F955E040449808B55601
88FDC68C75D E F955E040449808B55601
88FDC68C75D F F955E040449808B55601
88FDC68C75DDF955E040449808B55601
88FDC68C75DEF955E040449808B55601
88FDC68C75DFF955E040449808B55601
可能有用: http://feuerthoughts .blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html
这篇关于如何在Oracle中生成GUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!