

Ask HN: Can I declare varchar like this in an SQL Column? - markcrazyhorse

Hey,<p>I may be totally wrong here because i&#x27;m only a junior and not too sure but I was certain that the maximum varchar() that could be set was 255 varchar(255).<p>However, i&#x27;m working on a database at the moment which was developed by another team and they have varchar(9999).<p>Is that right? I have had a quick Google but can&#x27;t find it.<p>Cheers for advice in advance folks :)
======
onion2k
No database has a limit of 255 characters. Varchar limits are; MySQL - 65,535.
MS SQL Server 2005 - 8000 (or 2GB if you use varchar(max) ). Oracle 9i - 4000

These are not character limits. They're byte limits. If you're storing
multibyte strings (eg unicode-16, emoji, etc) then each character will take up
more than one 'space'.

But really, asking on HN? This is what StackOverflow is for.

~~~
stephenr
The OP is not as wrong as you suggest. Prior to MySQL 5.0.3, varchar was
limited to 255 bytes. Also, there is a maximum row length for all columns
which is 65,535 bytes, so the practical maximum size for a varchar column is
less, unless it's the only column in the table.

~~~
markcrazyhorse
Thanks for the reply - Very Useful

------
fasteo
You should post this question to stackoverflow.com

~~~
markcrazyhorse
I thought about that but SO is usually for more detailed questions etc. I have
seen similar questions like this be put on hold and slated by the users.
However, the above posters have answered my questions :)

~~~
fasteo
That´s usually the case if you post poorly written questions, both in content
and form, to SO. This is actually a good thing for you, as it forces you to
think harder about the problem.

And don´t be afraid of SO users. They are there to help and some slating from
time to time is good for your soul :)

