数据库中电子邮件地址的最佳长度是多少? [英] What is the optimal length for an email address in a database?

查看:2985
本文介绍了数据库中电子邮件地址的最佳长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做我的第一个数据库项目。

I am doing my first database project.

我在 EMAIL_ADDRESS

...
EMAIL_ADDRESS CHARACTER VARYING(20) NOT NULL, 
...

但是, John Saunders 使用 VARYING(256)
这表明我不一定正确理解VARYING。我理解这样,电子邮件地址的长度在我的情况下是20个字符,而Jodn是256个字符。

However, John Saunders uses VARYING(256). This suggests me that I have not necessarily understood the VARYING correctly. I understand it such that the length of an email-address is 20 characters in my case, while 256 for Jodn.

John的代码中的上下文

CREATE TABLE so."User"
     (
         USER_ID SERIAL NOT NULL,
         USER_NAME CHARACTER VARYING(50) NOT NULL,
         EMAIL_ADDRESS CHARACTER VARYING(256) NOT NULL,      /// Here
         HASHED_PASSWORD so.HashedPassword NOT NULL,
         OPEN_ID CHARACTER VARYING(512),                                                         
         A_MODERATOR BOOLEAN,
         LOGGED_IN BOOLEAN,
         HAS_BEEN_SENT_A_MODERATOR_MESSAGE BOOLEAN,
         CONSTRAINT User_PK PRIMARY KEY(USER_ID)
     );

我从未见过普通人使用的电子邮件地址超过20个字符。

I have never seen email addresses longer than 20 characters, used by ordinary people.

数据库中电子邮件地址的最佳长度是多少?

推荐答案

电子邮件地址的最大长度为254个字符。

The maximum length of an email address is 254 characters.

每个电子邮件地址由两部分组成。 @符号之前的局部部分,以及其后的域部分。在user@example.com中,本地部分是user,域部分是example.com。

Every email address is composed of two parts. The local part that comes before the '@' sign, and the domain part that follows it. In "user@example.com", the local part is "user", and the domain part is "example.com".

本地部分不能超过64字符和域部分不能超过255个字符。

The local part must not exceed 64 characters and the domain part cannot be longer than 255 characters.

电子邮件地址的本地+ @ +域部分的总长度不能超过254个字符。如 RFC3696勘误ID 1690 中所述。

The combined length of the local + @ + domain parts of an email address must not exceed 254 characters. As described in RFC3696 Errata ID 1690.

我从这里获得了此信息的原始部分

这篇关于数据库中电子邮件地址的最佳长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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