http://www.postgresql.org/docs/faqs/FAQ .htmlHi All,I want to use GUIDs for object IDs in my application. This means thatthey would be used for primary keys in PostgreSQL, and there would ofcourse be FKs pointing to them. A GUID is 128 bits, and can be in thefollowing possible formats:* 16 byte binary (but then I''d have to convert it to hex in my app)* 32 byte string (e.g., ''4162F7121DD211B2B17EC09EFE1DC403'')* hex string (e.g., 0x3271839C163D11D891F785398CC7932E)* Base 64 string (e.g., ''MnIAdBY9EdiR94U5jMeTLg=='')It looks like the hex option would be the best option, but there''s nonative hex format in PostgreSQL. Anyone have suggestions on what thebest approach might be? I can''t convert it to a number, really, because128 bit numbers aren''t too portable).Please Cc any replies to me, as I''m not subscribed to the mail list.Many TIA,David--David Wheeler AIM: dwTheory da***@kineticode.com ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7eJabber: Th****@jabber.orgKineticode. Setting knowledge in motion.[sm]---------------------------(end of broadcast)---------------------------TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html推荐答案 David Wheeler写道:David Wheeler writes:看起来像hex选项是最好的选择,但PostgreSQL中没有原生的十六进制格式。任何人都有关于最佳方法可能是什么的建议?我无法将其转换为数字,真的,因为 128位数字不太便于移动。) It looks like the hex option would be the best option, but there''s no native hex format in PostgreSQL. Anyone have suggestions on what the best approach might be? I can''t convert it to a number, really, because 128 bit numbers aren''t too portable). 使用bytea。它存储字节并允许转换成几种输出 格式。 - Peter Eisentraut pe ***** @ gmx.net --------------- ------------(广播结束)--------------------------- 提示8:解释分析是你的朋友Use bytea. It stores bytes and allows the conversion into several outputformats.--Peter Eisentraut pe*****@gmx.net---------------------------(end of broadcast)---------------------------TIP 8: explain analyze is your friend 2003年11月13日星期四,下午8:04,Peter Eisentraut写道:On Thursday, November 13, 2003, at 08:04 PM, Peter Eisentraut wrote:使用bytea。它存储字节并允许转换成几种输出格式。 Use bytea. It stores bytes and allows the conversion into several output formats. 字节与二进制或十六进制?当我只需要16个额外的4个字节时,添加 并不是一点浪费吗? 谢谢, David - David Wheeler AIM:dwTheory da *** @ kineticode.com ICQ:15726394 http://www.kineticode.com/ Yahoo!:dew7e Jabber: Th **** @ jabber.org Kineticode。设置运动知识。[sm] ---------------------------(广播结束) - ------------------------- 提示1:订阅和取消订阅命令转到 ma ******* @ postgresql.orgbytea with the binary or the hex? And isn''t it a bit of a waste to addthe extra 4 bytes when I''ll only ever need 16?Thanks,David--David Wheeler AIM: dwTheory da***@kineticode.com ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7eJabber: Th****@jabber.orgKineticode. Setting knowledge in motion.[sm]---------------------------(end of broadcast)---------------------------TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org David Wheeler写道:David Wheeler writes: bytea与二进制或十六进制? 二进制或十六进制是什么? 并且当我只是曾经需要16? bytea with the binary or the hex?Binary or hex what? And isn''t it a bit of a waste to add the extra 4 bytes when I''ll only ever need 16? 当然,如果你想避免这种情况,你必须实施自己的 数据类型。实际上,我认为有人已经为GUID做了这件事。如果 你搜索档案你可能会发现它。 - Peter Eisentraut pe ***** @ gmx.net --------------- ------------(广播结束)--------------------------- 提示6:您是否搜索了我们的列表档案? http:// archives.postgresql.orgSure, but if you want to avoid that, you''ll have to implement your owndata type. Actually, I think someone has already done that for GUID. Ifyou search the archives you might find out about it.--Peter Eisentraut pe*****@gmx.net---------------------------(end of broadcast)---------------------------TIP 6: Have you searched our list archives? http://archives.postgresql.org 这篇关于的GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 02:51