Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (4k points)
closed by

I'm coming from a SQL Server background. What would the equivalent data types be for the following in MySQL:

NVARCHAR - provides support for international, multi-byte characters for all languages

NVARCHAR(max) - allows for very long text documents

closed

4 Answers

0 votes
by (7.8k points)
 
Best answer
NVARCHAR: In MySQL, the equivalent data type for NVARCHAR would be VARCHAR. VARCHAR is a variable-length character string that can store both single-byte and multi-byte characters, providing support for international, multi-byte characters for all languages, similar to NVARCHAR in SQL Server. It allows you to specify the maximum length of the string you want to store.

NVARCHAR(max): MySQL does not have an exact equivalent to the NVARCHAR(max) data type in SQL Server. However, you can use the LONGTEXT data type in MySQL to store very long text documents. LONGTEXT can hold a large amount of text data, making it suitable for storing documents of considerable length.

MySQL's VARCHAR data type can handle both single-byte and multi-byte characters, making it suitable for storing international, multi-byte characters similar to NVARCHAR in SQL Server. While there is no direct equivalent to NVARCHAR(max) in MySQL, the LONGTEXT data type can be used to store very long text documents.
0 votes
by (8.7k points)
edited by

The closest equivalent to the above that types are

VARCHAR(n) CHARSET ucs2

But commonly people don’t use it.

A commonly used Equivalent SQL data type is 

VARCHAR(n) CHARSET utf8

The above data types are the same along encoding is different.

Check out our SQL Course to have a complete grip on SQL concepts.

0 votes
by (11.4k points)
In MySQL, the equivalent data type for NVARCHAR would be VARCHAR, which supports international, multi-byte characters for all languages. To store very long text documents, MySQL does not have a direct equivalent to NVARCHAR(max) in SQL Server. However, you can use the LONGTEXT data type, which can hold a large amount of text data, making it suitable for storing lengthy documents.
0 votes
by (13k points)

NVARCHAR in SQL Server is equivalent to VARCHAR in MySQL. For very long text documents, use LONGTEXT in MySQL.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 23, 2021 in SQL by RohitSingh (2.6k points)
0 votes
1 answer
asked Jan 6, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer

Browse Categories

...