0

Can anyone tell me what is the difference between varchar and nvarchar with the same character set and collate. Example:

varchar CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  

and

nvarchar CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci

Thank you!

1 Answers1

-1

Actually, MySQL do not have nvarchar() data types Click here for details

varchar() and nvarchar() are data types of sql-server and the difference is nvarchar support and unicode character mainly use for internationalisation but varchar() do not support unicode. details for sql-server nvarchar

Sujit Sharma
  • 110
  • 10
  • Can i ask you for one more? Does the ascii character set require less bytes per character than ther utf8mb4 character set. Is there any difference between them if there is 2 table with same data but using 2 diff character set – Phạm Tiến Hải Sep 30 '21 at 09:13
  • Exactly, Ascii character set requires less bytes(space) then utf8mb4 but it does not support for all international language and emoji. So, utf8mb4 is used more. I think two tables are created to consume less space, But nowadays space is not importance over the importance of unicode support – Sujit Sharma Sep 30 '21 at 09:57
  • Thank you again. But if a have column which store non utf8 data such as password or some kind of string id, should i use the ascii character set for it or just apply utf8mb4 for all column in database because you said space was not importance over the importance of unicode support. – Phạm Tiến Hải Sep 30 '21 at 12:14
  • Actually, utf8mb4 is compatible with all OS and Databases which comes to be great importance when you need to migrate database or OS in future. Hence I suggest to use utf8mb4 – Sujit Sharma Sep 30 '21 at 12:28
  • OK thank you for helping me. Have a nice day! – Phạm Tiến Hải Sep 30 '21 at 13:32
  • The [documentation](https://dev.mysql.com/doc/refman/5.6/en/charset-national.html) seems to differ from your answer. – user1191247 Feb 18 '23 at 16:07