Questions tagged [varchar]

A varchar or variable character field is a set of character data of indeterminate length.

A varchar or variable character field is a set of character data of indeterminate length. The term varchar refers to a data type of a field (or column) in a database management system. Varchar fields can be of any size up to the limit. In case of Microsft SQL Server, from SQL Server 2005 varchar fields don't need to be limited by using varchar(max).

1443 questions
1675
votes
21 answers

What is the difference between varchar and nvarchar?

Is it just that nvarchar supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using varchars?
stimms
  • 42,945
  • 30
  • 96
  • 149
963
votes
13 answers

Difference between text and varchar (character varying)

What's the difference between the text data type and the character varying (varchar) data types? According to the documentation If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
899
votes
9 answers

MySQL: Large VARCHAR vs. TEXT?

I've got a messages table in MySQL which records messages between users. Apart from the typical ids and message types (all integer types) I need to save the actual message text as either VARCHAR or TEXT. I'm setting a front-end limit of 3000…
Tom
  • 30,090
  • 27
  • 90
  • 124
708
votes
12 answers

What is the difference between char, nchar, varchar, and nvarchar in SQL Server?

What is meant by nvarchar? What is the difference between char, nchar, varchar, and nvarchar in SQL Server?
MrDatabase
  • 43,245
  • 41
  • 111
  • 153
663
votes
37 answers

MySQL Error #1071 - Specified key was too long; max key length is 767 bytes

When I executed the following command: ALTER TABLE `mytable` ADD UNIQUE ( `column1` , `column2` ); I got this error message: #1071 - Specified key was too long; max key length is 767 bytes Information about column1 and column2: column1 varchar(20)…
Steven
  • 24,410
  • 42
  • 108
  • 130
462
votes
7 answers

What is the string length of a GUID?

I want to create a varchar column in SQL that should contain N'guid' while guid is a generated GUID by .NET (Guid.NewGuid) - class System.Guid. What is the length of the varchar I should expect from a GUID? Is it a static length? Should I use…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
460
votes
2 answers

Difference between VARCHAR and TEXT in MySQL

When we create a table in MySQL with a VARCHAR column, we have to set the length for it. But for TEXT type we don't have to provide the length. What are the differences between VARCHAR and TEXT?
user3840485
  • 4,735
  • 3
  • 20
  • 22
353
votes
8 answers

What is the MySQL VARCHAR max size?

I would like to know what the max size is for a MySQL VARCHAR type. I read that the max size is limited by the row size which is about 65k. I tried setting the field to varchar(20000) but it says that that's too large. I could set it to…
user1832628
  • 3,859
  • 3
  • 16
  • 10
310
votes
4 answers

SQL Server Text type vs. varchar data type

I have variable length character data and want to store in SQL Server (2005) database. I want to learn some best practices about how to choose TEXT SQL type or choose VARCHAR SQL type, pros and cons in performance/footprint/function.
George2
  • 44,761
  • 110
  • 317
  • 455
248
votes
14 answers

What are the main performance differences between varchar and nvarchar SQL Server data types?

I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
246
votes
10 answers

Changing the maximum length of a varchar column?

I'm trying to update the length of a varchar column from 255 characters to 500 without losing the contents. I've dropped and re-created tables before but I've never been exposed to the alter statement which is what I believe I need to use to do…
Michael A
  • 9,480
  • 22
  • 70
  • 114
223
votes
10 answers

Is there a good reason I see VARCHAR(255) used so often (as opposed to another length)?

In multiple courses, books, and jobs, I have seen text fields defined as VARCHAR(255) as kind of the default for "shortish" text. Is there any good reason that a length of 255 is chosen so often, other than being a nice round number? Is it a…
Kip
  • 107,154
  • 87
  • 232
  • 265
222
votes
9 answers

Postgresql - change the size of a varchar column to lower length

I have a question about the ALTER TABLE command on a really large table (almost 30 millions rows). One of its columns is a varchar(255) and I would like to resize it to a varchar(40). Basically, I would like to change my column by running the…
Labynocle
  • 4,062
  • 7
  • 22
  • 24
218
votes
5 answers

Using varchar(MAX) vs TEXT on SQL Server

I just read that the VARCHAR(MAX) datatype (which can store close to 2GB of char data) is the recommended replacement for the TEXT datatype in SQL Server 2005 and Next SQL SERVER versions. If I want to search inside a column for any string, which…
user85116
  • 4,422
  • 7
  • 35
  • 33
217
votes
5 answers

Equivalent of varchar(max) in MySQL?

What is the equivalent of varchar(max) in MySQL?
David Basarab
  • 72,212
  • 42
  • 129
  • 156
1
2 3
96 97