GUID:varchar(36)与uniqueidentifier [英] GUID: varchar(36) versus uniqueidentifier

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

问题描述

我正在使用一个旧数据库,将GUID值存储为varchar(36)数据类型:

I'm working with a legacy database that stores GUID values as a varchar(36) data type:

CREATE TABLE T_Rows (
    RowID    VARCHAR(36) NOT NULL PRIMARY KEY,
    RowValue INT         NOT NULL
) 

INSERT T_Rows (RowID, RowValue) VALUES (NEWID(), 1)

我认为将GUID存储为唯一标识符将是可取的,因为它只有16个字节大小相对于36.

I would assume that storing a GUID as a uniqueidentifier would be preferable since it's only 16 bytes in size as opposed to 36.

将GUID存储为varchar有什么好处吗?

Are there any advantages to storing a GUID as a varchar?

推荐答案

也许只有你可以从SELECT语句读他们的事实(虽然我不认为这是特别有用的因为您可以使用select中的一个功能使Uniqueidentifiers显示)

Perhaps only the fact that you can 'read' them from a SELECT statement (although I don't think that's particularly useful as you can use a function in a select to make Uniqueidentifiers displayable).

如果表格很大,每行节省20个字节是相当可观的。

If the table is large, saving 20 bytes per row is considerable.

这篇关于GUID:varchar(36)与uniqueidentifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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