在sql server 2000下可以
create table tbl
(
  oid uniqueidentifier
)
insert tbl(oid) values(newid())
请问Oracle下的GUID是怎么样的,
因为需要数据结构支持多数据库

解决方案 »

  1.   

    用序列号sequence
    insert into tbl(id,....)
    values (your_seq.nextval,....)
      

  2.   

    两种方法
    方法一:
      用触发器建一个序列
    create sequence a_seq increment by 1 start with 100;
    建一个触发器
    create or replace trigger t_a
    before insert on a
    for each row
    begin
         select s_a.nextval into :new.b from dual;
    end;方法二:
      建一个序列
         create sequence a_seq increment by 1 start with 100;
       使用
      insert into tbl(id,....)
         values (a_seq.nextval,....)
      

  3.   

    一样可以使用guidALTER TABLE locations ADD (uid_col RAW(32));
    UPDATE locations SET uid_col = SYS_GUID();
    SELECT location_id, uid_col FROM locations;
    LOCATION_ID UID_COL
    ----------- ----------------------------------------
    1000 7CD5B7769DF75CEFE034080020825436
    1100 7CD5B7769DF85CEFE034080020825436
    1200 7CD5B7769DF95CEFE034080020825436
    1300 7CD5B7769DFA5CEFE034080020825436
    ...