Varchar(max) 列不允许作为 SQL Server 中的主键 [英] Varchar(max) column not allowed to be a Primary Key in SQL Server

查看:37
本文介绍了Varchar(max) 列不允许作为 SQL Server 中的主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Varchar(max) 列不允许作为 SQL Server 中的主键.

Varchar(max) column not allowed to be a Primary Key in SQL Server.

可以作为主键的 varchar 类型的最大长度是多少.

What is the max length of a varchar type that can be made a primary key.

这可能是一个不好的做法,但遇到了这种情况.

This might be a bad practice, but came across the situation.

推荐答案

900 字节是主键的最大长度,在我看来这是个坏主意,你为什么不使用代理键呢?

900 bytes is the max length for a primary key, this is a bad idea in my opinion, why don't you use a surrogate key instead?

这篇关于Varchar(max) 列不允许作为 SQL Server 中的主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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