Is it possible to auto-generate a GUID into an Insert statement?
Also, what type of field should I use to store this GUID?
Thanks!
Is it possible to auto-generate a GUID into an Insert statement?
Also, what type of field should I use to store this GUID?
Thanks!
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');
The preferred datatype for storing GUIDs is RAW(16).
Check this link, it may be useful to you
http://feuerthoughts.blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html
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.