What does VARCHAR(256) mean ? Is it a special data type?

I’ve seen an unusual data type in this exercise: https://www.codecademy.com/courses/learn-sql/lessons/multiple-tables/exercises/inner-join-ii
called VARCHAR(256)
Does anybody know what is it ?

1 Like

Hey there - welcome to the forums!

Yes, and it’s not actually that unusual.

VARCHAR(256) is basically a 256-character variable length string - i.e. you can store a 3-character string in it, say lol, or a longer string, like this is a longer example of a string of text!, so long as it’s less than 256 characters in total.

VARCHAR is the bit which tells you “this is a variable length string”, and (256) is what tells you the maximum length. (VARCHAR can go up to 65535 characters long, if memory serves.)

There’s some more information about it on W3Schools if you like. That page is aimed at MySQL/MS SQL, but the general idea is the same for most DB engines. (If in doubt, refer to the documentation for the database engine you’re running.) :slight_smile:

Hope that helps. :smiley:

1 Like

Thanks a lot. Now I’ve extended my knowledge of SQL

1 Like

No problem.

If you get stuck with anything else, let us know. :slight_smile: