This is a discussion on Varchar vs. text within the PHP Language forums, part of the PHP Programming Forums category; I was lately wandering what would be the advantage of using varchar instead of text column data type in a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
On 2004-01-26, Berislav Lopac <berislav.lopac@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 |
|
|||
|
hi!
On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac" <berislav.lopac@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/ |
|
|||
|
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 > > |
|
|||
|
Hi Berislav!
On Mon, 26 Jan 2004 21:22:56 +0000, "Capt. Beefheart" <Captain.Beefheart@crystalfalls.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/ |
|
|||
|
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" <jochen.daum@cans.co.nz> napisal w wiadomosci news:vjta10h9rha6aj16aolcuijlvph5i6r8dr@4ax.com... > hi! > > On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac" > <berislav.lopac@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/ |
|
|||
|
Hi Chung! On Mon, 26 Jan 2004 21:29:12 -0500, "Chung Leong" <chernyshevsky@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" <jochen.daum@cans.co.nz> napisal w wiadomosci >news:vjta10h9rha6aj16aolcuijlvph5i6r8dr@4ax.com.. . >> hi! >> >> On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac" >> <berislav.lopac@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/ |