Subject | Re: [firebird-support] Primary Key - GUID |
---|---|
Author | Pavel Menshchikov |
Post date | 2006-01-25T17:47:17Z |
Hello,
a> I would like to use the GUID as primary key field.
a> However, the BIGINT is 64 bit and it cannot be used to store GUID.
a> What alternative data type can I use to store the GUID?
a> If say, define the primary fieled as VARCHAR(38), is the index wide
a> enough to do sorting or searching ?
As Adam said, use CHAR. To generate GUIDs you need a UDF (uuidlib, for
example). Note that "compact" form of a GUID (UUID, which could be
saved as CHAR(22)) is more suitable/efficient for indexing in FB than
a "regular" form of a GUID (which could be saved as CHAR(36) excluding
brackets).
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com
a> I would like to use the GUID as primary key field.
a> However, the BIGINT is 64 bit and it cannot be used to store GUID.
a> What alternative data type can I use to store the GUID?
a> If say, define the primary fieled as VARCHAR(38), is the index wide
a> enough to do sorting or searching ?
As Adam said, use CHAR. To generate GUIDs you need a UDF (uuidlib, for
example). Note that "compact" form of a GUID (UUID, which could be
saved as CHAR(22)) is more suitable/efficient for indexing in FB than
a "regular" form of a GUID (which could be saved as CHAR(36) excluding
brackets).
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com