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?
There is no specific datatype for email, so your only options are to either create a validation rule for the field that checks your entry is correct, or, the best way to do it would be to validate your email in the user interface itself.
And as for varchar vs nvarchar, the RFC had different allowed characters for each part of the email address but all the allowable characters for email addresses are all contained in the varchar range.
Numeric Data Types The default value for size is 1. Zero is considered as false, nonzero values are considered as true. An exact fixed-point number. The total number of digits is specified in size.
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
Since the max lenght for a email is 254 characters, i would recommend you to use nvarchar(255). That should be enough
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With