3

If a blog post is 200 characters long, will varchar(6500) only consume the space of varchar(200)?

Will this be more efficient than using TEXT or LONGTEXT?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
user1794491
  • 31
  • 1
  • 1
  • 2
  • 3
    Yes, AFAIK, if a string is 200 chars long, it will take up space needed for 200 chars only. – asprin Nov 02 '12 at 14:25
  • Did you read the manual? It's all explained there. Also, most RDBMS have deprecated types such as `TEXT` and direct you to use `VARCHAR(MAX)` and other similar types instead. *(Which would also be mentioned in the manual...)* – MatBailie Nov 02 '12 at 14:29
  • 1
    Putting any kind of character limit on a blogging system seems rather awkward to me. A TEXT/LONGTEXT would seem more appropriate to give the blogger full freedom of speech :) – Oldskool Nov 02 '12 at 14:33

2 Answers2

2

TEXT is stored off the table it has reference of it only.

While

VARCHAR is stored inline with the table and usually used with less size. You can use it to max 65535 but very bad actually in terms of performance.

So that you can optimized table and queries, performance may very with DBMS. If you have variable but larger string I would suggest using TEXT

Waqar Alamgir
  • 9,828
  • 4
  • 30
  • 36
0

Variable-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8,000. Storage size is the actual length in bytes of the data entered, not n bytes. The data entered can be 0 characters in length. The SQL-92 synonyms for varchar are char varying or character varying.

http://msdn.microsoft.com/en-us/library/aa258242%28v=sql.80%29.aspx

Zyku
  • 1,429
  • 2
  • 23
  • 37