使用“varchar”作为主键?馊主意?或确定? [英] Using "varchar" as the primary key? bad idea? or ok?

查看:239
本文介绍了使用“varchar”作为主键?馊主意?或确定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用varchar作为主键真的很不好吗?

Is it really that bad to use "varchar" as the primary key?

(将存储用户文档,是可以超过2亿个文档)

(will be storing user documents, and yes it can exceed 2+ billion documents)

推荐答案

完全取决于数据。有很多完全合法的情况下,你可以使用 VARCHAR 主键,但如果有人可能想更新有问题的某一点的最可能的机会在未来,不要使用它作为关键。

It totally depends on the data. There are plenty of perfectly legitimate cases where you might use a VARCHAR primary key, but if there's even the most remote chance that someone might want to update the column in question at some point in the future, don't use it as a key.

这篇关于使用“varchar”作为主键?馊主意?或确定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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