Reputation: 253
What data type should I use for an email? Just started to learn SQL, and I tried to make some columns, here's table for ID, Username, Password, Money, and Email.
Did I make that correctly?
Upvotes: 19
Views: 98940
Reputation: 1961
The right value of data lenght for the email field is database-agnostic. If you are also considering standard SQL types, the same can be said for data type, that is a string. You can take a look at this.
Upvotes: 0
Reputation: 572
It's good to go with NVARCHAR(320) - 64 characters for local part + @ + 255 for domain name.
You Use varchar(255) and nvarchar(255) Data type
Upvotes: 17
Reputation: 124
Since the max lenght for a email is 254 characters, i would recommend you to use nvarchar(255). That should be enough
Upvotes: 8
Reputation:
you can use varchar as your data type for email column as emails are usually composed of letters, numbers and special characters.
Upvotes: 4