472,352 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

varchar vs. text

I curious about the benefits of a varchar over text. Is it speed,
size? If so, how much speed, size? Is a varchar(64) and a text with 64
chars the same size? I'm inclined to make all my varchars into text so
I don't have to worry about inserting something to big.

TIA,
Michael
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #1
4 8608
Michael Garriss <mg******@earthlink.net> writes:
I curious about the benefits of a varchar over text.
1. Compliance to the letter of the SQL spec.
2. Ability to define a maximum length, if you happen to feel the need to
impose a specific maximum length. (If you don't have a good reason
to impose any particular max length, this is a minus not a plus,
because the spec says you have to pick one anyway.)
Is it speed,


It's a loser on speed because of the extra cycles spent to check the
max length. Other than those cycles, there is no difference.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #2
Tom Lane wrote:
Michael Garriss <mg******@earthlink.net> writes:

I curious about the benefits of a varchar over text.


1. Compliance to the letter of the SQL spec.
2. Ability to define a maximum length, if you happen to feel the need to
impose a specific maximum length. (If you don't have a good reason
to impose any particular max length, this is a minus not a plus,
because the spec says you have to pick one anyway.)
Is it speed,


It's a loser on speed because of the extra cycles spent to check the
max length. Other than those cycles, there is no difference.

regards, tom lane

Thanks for the quick response.

Michael

P.S. The code I'm writing is going to be ported to MySQL by a friend.
Do you have any idea if TEXT is supported over there?
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #3
On Wed, 2003-09-17 at 22:59, Michael Garriss wrote:
I curious about the benefits of a varchar over text. Is it speed,
size? If so, how much speed, size? Is a varchar(64) and a text with 64
chars the same size? I'm inclined to make all my varchars into text so
I don't have to worry about inserting something to big.


An analyst would say that "correctness" is a reason for specifying
a max length. For example, in t_names, I could stick "War and Peace"
into first_name, but, obviously, that's not "correct".

CREATE TABLE t_names (
first_name TEXT,
last_name TEXT );

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@cox.net
Jefferson, LA USA

"(Women are) like compilers. They take simple statements and
make them into big productions."
Pitr Dubovitch
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #4
In article <3F**************@earthlink.net>,
Michael Garriss <mg******@earthlink.net> writes:
P.S. The code I'm writing is going to be ported to MySQL by a friend.
Shame on you for having a friend using MySQL ;-)
Do you have any idea if TEXT is supported over there?


Yes: http://www.mysql.com/doc/en/BLOB.html
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Berislav Lopac | last post by:
I was lately wandering what would be the advantage of using varchar instead of text column data type in a database (specificall MySQL, but this...
7
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS....
6
by: Bill | last post by:
In an effort to improve the speed of queries against my main table, I'll be indexing a column whose data type is varchar(50). Would I be better...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db...
0
by: Edward Mitchell | last post by:
I have a database with text string fields defined by varchar(nnn). When I request from the user the text from a textbox, I'd like to set the...
5
by: dmhendricks | last post by:
Greetings, I have a question. I work on some SQL2k/ASP.NET apps at work. My predacessor, who created the databases/tables seemed to have liked...
10
by: Techie | last post by:
what's the difference of the two data types?
6
by: mike | last post by:
so I keep optimizing my fields down to the minimum character length necessary i.e., varchar(15), then I find out a month later its gotta get...
0
Krishna Ladwa
by: Krishna Ladwa | last post by:
In Sql Server 2000 Version, I found that no Notification message box appears when converting text column to varchar but the data gets truncated to...
4
by: Nick Chan | last post by:
all these while i've only used varchar for any string i heard from my ex-boss that char helps speed up searches. is that true? so there are...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.