Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between VARCHAR NVARCHAR in SQLite

Tags:

sqlite

What is the difference between varchar and nvarchar in SQLite

like image 666
Hiyasat Avatar asked Oct 14 '10 06:10

Hiyasat


People also ask

What is the difference between NVARCHAR and VARCHAR?

The key difference between varchar and nvarchar is the way they are stored, varchar is stored as regular 8-bit data(1 byte per character) and nvarchar stores data at 2 bytes per character. Due to this reason, nvarchar can hold upto 4000 characters and it takes double the space as SQL varchar.

Should I use NVARCHAR or VARCHAR?

Today's development platforms or their operating systems support the Unicode character set. Therefore, In SQL Server, you should utilize NVARCHAR rather than VARCHAR. If you do use VARCHAR when Unicode support is present, then an encoding inconsistency will arise while communicating with the database.

Which is faster VARCHAR or NVARCHAR?

Each character of an nvarchar column requires 2 bytes of storage whereas a varchar column requires 1 byte per character. Potentially, varchar will be quicker but that may well mean that you cannot store the data that you need.

What is VARCHAR in SQLite?

You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N.


1 Answers

In Microsoft SQL Server, VARCHAR is ASCII and NVARCHAR is Unicode (UTF-16). In SQLite, all text is Unicode, so it's not relevant. In any case, SQLite is loosely typed so it wouldn't make a difference anyways. See http://www.sqlite.org/datatype3.html:)

like image 133
Daniel Lo Nigro Avatar answered Oct 03 '22 22:10

Daniel Lo Nigro