Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

could mysql table cell hold unlimited string?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I was wondering if a mysql table cell could hold an unlimited length string? I can't seem to make it hold more than 255 charecters long. Thanks in advance for any help or suggestions.

CREATE TABLE about (
data varchar(255) default NULL
);

 
You should use another field type, for example TEXT which can hold as much as you've got free space on your HD. The TEXT field type is also called MEMO (for example in Ms Access).


Charl
 
or LONGTEXT which is even bigger ;0) ***************************************
Party on, dudes!
[cannon]
 
"for example TEXT which can hold as much as you've got free space on your HD."

Well, not exactly. It depends on what bit your Operating System/processor is at. For example, a 64bit processor can hold a field that is 2 terabytes in size, where as with 32 bit, its more like 2 gigabits.

-Vic vic cherubini
krs-one@cnunited.com
 
It might be worth seeing this from the MySQL manual for types TEXT and BLOB:

If you want to use GROUP BY or ORDER BY on a BLOB or TEXT column, you must convert the column value into a fixed-length object. The standard way to do this is with the SUBSTRING function. For example:
mysql> select comment from tbl_name,substring(comment,20) as substr
ORDER BY substr;

If you don't do this, only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024; this value can be changed using the -O option when starting the mysqld server. You can group on an expression involving BLOB or TEXT values by specifying the column position or by using an alias:
mysql> select id,substring(blob_col,1,100) from tbl_name
GROUP BY 2;
mysql> select id,substring(blob_col,1,100) as b from tbl_name
GROUP BY b;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top