473,915 Members | 5,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Varchar vs. text

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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.

Berislav
Jul 17 '05 #1
7 19722
Berislav Lopac wrote:
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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.

Berislav

I prefer VARCHAR since some other RDBMS support VARCHAR but not
TEXT. If you will never migrate it doesn't matter, but if you
ever do it may.

HTH
Jerry

Jul 17 '05 #2
On 2004-01-26, Berislav Lopac <be************ @dimedia.hr> wrote:
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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.


The exact differences are mentionned in the MySQL manual.

--
http://home.mysth.be/~timvw
Jul 17 '05 #3
hi!

On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
<be************ @dimedia.hr> wrote:
I was lately wandering what would be the advantage of using varchar insteadof text column data type in a database (specificall MySQL, but this might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.


Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
default]), so you would have an unnecessary page hit for certain size
varchars.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #4
Berislav

I would imagine that varchar and text are from the days when disk space
was at a premium, that is, there wasn't much of it. Consquently varchar
would be used unless large amounts of text were going to be inserted
into a field. Of course with the problem of disk space no longer an
issue varchar could be considered defunct. Well at least in MySQL. Other
RDBMS's only use BLOB fields which can't be indexed.

Beefy

Berislav Lopac wrote:
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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.

Berislav


Jul 17 '05 #5
Hi Berislav!

On Mon, 26 Jan 2004 21:22:56 +0000, "Capt. Beefheart"
<Ca************ ***@crystalfall s.com> wrote:
Berislav

I would imagine that varchar and text are from the days when disk space
was at a premium, that is, there wasn't much of it. Consquently varchar
would be used unless large amounts of text were going to be inserted
into a field. Of course with the problem of disk space no longer an
issue varchar could be considered defunct. Well at least in MySQL. Other
RDBMS's only use BLOB fields which can't be indexed.
Not diskspace directky, but disk page accesses are *THE* premium, when
working with databases. Nearly all optimisations come down to
minimizing disk access. As soon as your database grows out of your
main memory, it is an issue.

HTH, Jochen
Beefy

Berislav Lopac wrote:
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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.

Berislav


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #6
Yup. Text/ntext fields are agonizingly slow in MSSQL 2000. Rows are limited
to 8000 bytes, so sometimes you're forced to use them. Accessing varchar
wider than 255 is a major pain too using PHP.

Uzytkownik "Jochen Daum" <jo*********@ca ns.co.nz> napisal w wiadomosci
news:vj******** *************** *********@4ax.c om...
hi!

On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
<be************ @dimedia.hr> wrote:
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 might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.


Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
default]), so you would have an unnecessary page hit for certain size
varchars.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

Jul 17 '05 #7

Hi Chung!

On Mon, 26 Jan 2004 21:29:12 -0500, "Chung Leong"
<ch***********@ hotmail.com> wrote:
Yup. Text/ntext fields are agonizingly slow in MSSQL 2000. Rows are limited
to 8000 bytes, so sometimes you're forced to use them. Accessing varchar
wider than 255 is a major pain too using PHP.
I actually thought this is a FreeTDS issue. If you set the Version to
7.0, eg. export TDSVER=7.0, (or similar for SQL 2000) you have no
problem retrieving 8000 chars.

For most applications I'm quite happy to use varchar. If it gets
bigger you have to consider the backup process as well anyway and then
it gets tricky.

HTH, Jochen

Uzytkownik "Jochen Daum" <jo*********@ca ns.co.nz> napisal w wiadomosci
news:vj******* *************** **********@4ax. com...
hi!

On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
<be************ @dimedia.hr> wrote:
>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 might
>also be the case for other databases)? I mean, both of them are variable
>length, both can be indexed, and text can hold a lot more data...
>
>I'm just looking for some other opinions on the subjects.


Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
default]), so you would have an unnecessary page hit for certain size
varchars.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #8

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

Similar topics

5
8602
by: adrian | last post by:
hi all this is my first post to this group, so pls bear with me while i try to make some sense. i am trying to create a sproc which uses dynamic sql to target a particuar table eg. '.' and perform some actions. i am using @tableID as a passes parameter for the sproc.
7
6226
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 architecture is built solely for frustration and I hope to make it better soon. Unfortunately, there is never a non-crucial time in which we can do an upgrade, so we are stuck for now. Point 1: There are multiple tables: students, courses, cross-reference
2
5158
by: Karen Sullivan | last post by:
Hi, all. I'm fairly new to SQL, and I have been trying to create a table from a text file. I have been looking at this for days, and can't find the problem. I get a syntax error " Line 55: Incorrect syntax near 'DateUpdated'." Here is the query. Any suggestions would be appreciated, as I am trying to learn and improve. Use ACH go if exists (select * from dbo.sysobjects where id =
3
2837
by: m.ramana | last post by:
Given a string it should convert it to a proper text. Example: if you passed a string 'Cat in the hat', I want 'Cat In The Hat' Curious about few things, Does sql have Instr OR Split(like VB) functionality Anybody can help??
12
3209
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
11
2950
by: panic attack | last post by:
Hello everbody, Our system is using Sql Server 2000 on Windows XP / Windows 2000 We have a text file needs to be imported into Sql Server 2000 as a table. But we are facing a problem which is, Sql Server claims that it has a character size limit ( which is 8060 ) so it cant procceed the import operation if the text file has a record bigger then 8060. The records , in the text file, have a size bigger then 8060. So we wont be able to...
3
3964
by: Daniel Wetzler | last post by:
Dear MSSQL- experts, I have a strange problem with SQLSERVER 2000. I tried to export a table of about 40000 lines into a text file using the Enterprise manager export assitant. I was astonished to get an exported text file of about 400 MB instead 16 MB which is the normal size of that data. By examining this file with a text editor I found that the file included alongside the data of my table MANY zeros which caused the big file size.
0
1755
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 the given size for the varchar. Whereas it appears when you convert the varchar column to text column. Do this through Enterprise Manager Console Create a New table with a column as varchar datatype from Enterprise Manager  table created  Open the table and add one row  Successfully added the...
4
8875
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 these: 1) char with index 2) char without index 3) char with clustered index
1
1993
by: codferrow | last post by:
Hello, I have a small issue with a web-search engine I'm working on. The main table is constantly growing (1 insert per second, currently 150 000 records) and it has full-text indexes on 2 fields that contain over 20 000 characters on each row. The thing is, as I could observe, that when multiple different full-text searches are made in appropiate period of time, the query doesn't take so much to respond (though i couldn't quite say it's...
0
10039
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5944
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.