18

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?

enter image description here

TylerH
  • 20,799
  • 66
  • 75
  • 101
user9745220
  • 213
  • 1
  • 2
  • 13

4 Answers4

16

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

ravi polara
  • 564
  • 3
  • 14
8

Since the max lenght for a email is 254 characters, i would recommend you to use nvarchar(255). That should be enough

4

you can use varchar as your data type for email column as emails are usually composed of letters, numbers and special characters.

0

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.

Cheshire Cat
  • 1,941
  • 6
  • 36
  • 69