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
187
votes
5 answers

Difference between BYTE and CHAR in column datatypes

In Oracle, what is the difference between : CREATE TABLE CLIENT ( NAME VARCHAR2(11 BYTE), ID_CLIENT NUMBER ) and CREATE TABLE CLIENT ( NAME VARCHAR2(11 CHAR), -- or even VARCHAR2(11) ID_CLIENT NUMBER )
Guido
  • 46,642
  • 28
  • 120
  • 174
178
votes
5 answers

What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL?

John uses CHARACTER VARYING in the places where I use VARCHAR. I am a beginner, while he is an expert. This suggests me that there is something which I do not know. What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL?
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
129
votes
8 answers

Is the LIKE operator case-sensitive with SQL Server?

In the documentation about the LIKE operator, nothing is told about the case-sensitivity of it. Is it? How to enable/disable it? I am querying varchar(n) columns, on an Microsoft SQL Server 2005 installation, if that matters.
Marcel
  • 15,039
  • 20
  • 92
  • 150
114
votes
1 answer

PostgreSQL: ERROR: operator does not exist: integer = character varying

Here i am trying to create view as shown below in example: Example: create view view1 as select table1.col1,table2.col1,table3.col3 from table1 inner join table2 inner join table3 on table1.col4 = table2.col5 /* Here col4 of…
Sarfaraz Makandar
  • 5,933
  • 16
  • 59
  • 84
110
votes
8 answers

How long should SQL email fields be?

I recognize that an email address can basically be indefinitely long so any size I impose on my varchar email address field is going to be arbitrary. However, I was wondering what the "standard" is? How long do you guys make it? (same question for…
Mala
  • 14,178
  • 25
  • 88
  • 119
101
votes
5 answers

MySQL VARCHAR Lengths and UTF-8

In MySQL, if I create a new VARCHAR(32) field in a UTF-8 table does it means I can store 32 bytes of data in that field or 32 chars (multi-byte)?
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
99
votes
10 answers

How to get the size of a varchar[n] field in one SQL statement?

Suppose that I have a SQL table that has a varchar[1000] field called "Remarks". I would like to craft a single SQL statement, which when executed, will return 1000, or whatever the size of the varchar field might be changed to in the…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
93
votes
1 answer

Postgres: Convert varchar to text

I screwed up and created a column as a varchar(255) where that is no longer sufficient. I've read that varchar has no performance benefits over text on Postgres, and so would like to convert the varchar to a text column in a safe way that preserves…
William Jones
  • 18,089
  • 17
  • 63
  • 98
92
votes
5 answers

When increasing the size of VARCHAR column on a large table could there be any problems?

I'm using SQL Server 2008 and I need to make a VARCHAR field bigger, from (200 to 1200) on a table with about 500k rows. What I need to know is if there are any issues I have not considered. I will be using this TSQL statement: ALTER TABLE…
Paul T Davies
  • 2,527
  • 2
  • 22
  • 39
84
votes
7 answers

varchar(max) everywhere?

Is there any problem with making all your Sql Server 2008 string columns varchar(max)? My allowable string sizes are managed by the application. The database should just persist what I give it. Will I take a performance hit by declaring all string…
BowserKingKoopa
  • 2,701
  • 3
  • 33
  • 40
81
votes
4 answers

Can I use VARCHAR as the PRIMARY KEY?

I have a table for storing coupons/discounts, and I want to use the coupon_code column as the primary key, which is a VARCHAR. My rationale is that, each coupon will have a unique code, and the only commands I will be running are SELECT ... FROM ...…
Mike Brady
  • 843
  • 1
  • 6
  • 6
78
votes
3 answers

MySQL VARCHAR size?

If I have a VARCHAR of 200 characters and that I put a string of 100 characters, will it use 200 bytes or it will just use the actual size of the string?
SBSTP
  • 3,479
  • 6
  • 30
  • 41
78
votes
4 answers

SQL unique varchar case sensitivity question

I'm trying to populate a SQL table with a list of words. The table itself it pretty simple: CREATE TABLE WORDS( ID BIGINT AUTO_INCREMENT, WORD VARCHAR(128) NOT NULL UNIQUE, PRIMARY KEY(ID) ); The problem I'm running into is this: when I do…
Seth
  • 5,596
  • 8
  • 42
  • 56
76
votes
7 answers

Why does VARCHAR need length specification?

Why do we always need to specify VARCHAR(length) instead of just VARCHAR? It is dynamic anyway. UPD: I'm puzzled specifically by the fact that it is mandatory (e.g. in MySQL).
Fixpoint
  • 9,619
  • 17
  • 59
  • 78
73
votes
2 answers

What are the optimum varchar sizes for MySQL?

How does MySQL store a varchar field? Can I assume that the following pattern represents sensible storage sizes : 1,2,4,8,16,32,64,128,255 (max) A clarification via example. Lets say I have a varchar field of 20 characters. Does MySQL when creating…
ae.
  • 1,670
  • 1
  • 14
  • 19
1
2
3
96 97