数据库中的名称字段应设置多大?
有一个老问题< /a> 这就是问这个问题,但是数据库和不言而喻的标准已经发生了很多变化。
我通常遵循的规则是永远不要创建字段大小text
或memo
,即使它可以加快数据库速度。主要是因为如果输入接口没有限制,有人可能会淹没并可能破解数据库。
也就是说,现在表中名称字段的一般做法是什么?
CREATE TABLE foo (
name_first Varchar(64) Not Null
, name_middle Varchar(64)
, name_last Varchar(64) Not Null
);
我认为这是我的默认设置,但其他人如何处理外国名字和超过 3 个名字?
There's an old question that asks this very thing, but a lot has changed in databases and unspoken standards.
I generally live by the rule as to never make a field size text
or memo
, even if it speeds up the database. Primarily because someone could flood and possibly hack the db if there are no restrictions in the input interface.
That said, what is the general practice these days for name fields in a table?
CREATE TABLE foo (
name_first Varchar(64) Not Null
, name_middle Varchar(64)
, name_last Varchar(64) Not Null
);
I think is my default, but how are others coping with foreign names and more than 3 names?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那应该足够了。我们有数以百万计的来自各个国家的名字,最长的姓氏有 29 个字符。我还会为 Jr. Sr. III 等添加个人后缀字段。
That should be plenty. We have millions of names from all nationalities and our longest lastname is 29 characters. I would add a personalsuffix field as well for Jr. Sr. III etc.
我的理论是,拥有更多比需要一些更好。为什么不使用 varchar(100) ?
My theroy is, is better to have a lot more than to need a few. why not to use varchar(100)?