的GUID [英] GUIDs

查看:99
本文介绍了的GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想在我的应用程序中使用GUID作为对象ID。这意味着它们将被用于PostgreSQL中的主键,并且当然会有FK指向它们的
。 GUID是128位,并且可以按照可能的格式在

中:


* 16字节二进制(但我必须将其转换为在我的应用程序中以十六进制形式)

* 32字节字符串(例如,''4162F7121DD211B2B17EC09EFE1DC403'')

*十六进制字符串(例如,0x3271839C163D11D891F785398CC7932E)

* Base 64字符串(例如,''MnIAdBY9EdiR94U5jMeTLg =='')


看起来hex选项是最好的选择,但是没有
PostgreSQL中的
原生十六进制格式。任何人都对

最佳方法有什么建议?我不能将它转换为数字,真的,因为

128位数字不太便携。)


请抄送任何回复我,因为我没有订阅邮件列表。


很多TIA,


David


-

David Wheeler AIM:dwTheory
da *** @ kineticode.com ICQ:15726394
http://www.kineticode.com/ 雅虎!:dew7e

Jabber: Th****@jabber.org

Kineticode。设置运动知识。[sm]

---------------------------(广播结束) - -------------------------

提示5:您检查过我们广泛的常见问题解答吗?
http://www.postgresql.org/docs/faqs/FAQ .html

Hi All,

I want to use GUIDs for object IDs in my application. This means that
they would be used for primary keys in PostgreSQL, and there would of
course be FKs pointing to them. A GUID is 128 bits, and can be in the
following 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 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).

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!: dew7e
Jabber: Th****@jabber.org
Kineticode. 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 output
formats.

--
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.org



bytea with the binary or the hex? And isn''t it a bit of a waste to add
the 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!: dew7e
Jabber: Th****@jabber.org
Kineticode. 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.org



Sure, but if you want to avoid that, you''ll have to implement your own
data type. Actually, I think someone has already done that for GUID. If
you 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆