large text bits
Moderator: General Moderators
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
large text bits
what would be the best way to store large chiunks of text in a mysql database? right now I'm using varchar(255) which i'm not happy with because its just not big enough. I tried to use blob or text or whatever and couldn't work it out.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
Additionaly, text field type provides you with mysql full-text search ability. Check the manual http://www.mysql.com/doc/en/BLOB.html
Below is a trick that I discovered for obtaining varchar texts larger than 255 characters when fetching rows using mssql. Let us say that you have a table T with a field F of type varchar(2000). A typical select statement for obtaining F from T looks like this:
Here $row[0] will be limited to a maximum of 255 characters (at least in my version of the mssql library).
My modified query is:
This makes the DB-library believe that the character field is actually a text field, and the 255 character limit is removed.
I hope this helps someone
Code: Select all
$result = mssql_query("select F from T", $connection);
$row = mssql_fetch_row($result);My modified query is:
Code: Select all
$result = mssql_query("select convert(text,F) as F from T, $connection);I hope this helps someone
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
You should tailor the text field as best you can. I usually get away with using MEDIUMTEXT for my column definition.
I think there's an overhead if you use an unnecessarily large column definition. For the same reason you don't use VARCHAR(255) for every column as it is a waste of space work out what realistically is the maximum text field you would need. It's all in the MySQL manual how many bytes you can store in each.
I think there's an overhead if you use an unnecessarily large column definition. For the same reason you don't use VARCHAR(255) for every column as it is a waste of space work out what realistically is the maximum text field you would need. It's all in the MySQL manual how many bytes you can store in each.