GUID: varchar(36) versus uniqueidentifier

后端 未结 5 1245
孤城傲影
孤城傲影 2021-02-19 01:12

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,
            


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-02-19 01:58

    I would go with uniqueidentifier for many reasons such as,

    it will take less space; it's unique so it can not be duplicated. It's much better for comparisons and specially performance related issues as well as easy to get unique default value etc.

    I would use uniqueidentifier unless I need to use varchar for very specific reason.

提交回复
热议问题