| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 615
![]() ![]() ![]() | PHP Basic Help I am currently reading from the PHP and MySQL 2nd Edition Dummies book. And I am kind of stuck on what this means. I seem not to understand it. Any help greatly appreciated. On the book, I am on page 57, and on the section about Variable-length format. It says: "In this format, MySQL stores the string in a field that is the same length as the string. You still specify a length for the string, but if the string is shorter than the specified length, MySQL only uses the space required rather than leaving the extra space empty. If the string is longer than the space specified, the extra characters are not stored." OK. So basically, what I think this means is that for instance if the field is specified with a length of 10. If the string is shorter than the specified length, MySQL ignores the extra space required, and uses the string as it is. If the string is longer than the specified space, the extra characters aren't stored. ????: NamePros.com http://www.namepros.com/programming/284281-php-basic-help.html Well, if that's true, its kind of the same like a fixed-length format, but oh well. If it isn't, please could you correct me. Thanks. Ben.
__________________ My personal tech blog |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 390
![]() ![]() ![]() | Yup i think you got it. So if my field has a limit of 10 characters and i enter 5, then it will only store 5 characters and leave the otherrs blank. If i enter 15 characters though... it will only store the first 10 and cut off the rest. Just common sense really MySQL isn't out there to confuse you, most of its using your initiative. Good luck with PHP!
__________________ -Beaver6813.com - Web Developer Extraordinaire! |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 615
![]() ![]() ![]() | thanks understand it now
__________________ My personal tech blog |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 390
![]() ![]() ![]() | np's
__________________ -Beaver6813.com - Web Developer Extraordinaire!
Last edited by beaver6813; 01-21-2007 at 11:41 PM.
|
| |
| | #5 (permalink) | ||||
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=284281 Actually no it is not saying that. The quote states that if the string is shorter than the specified length then the memory used by that field will be the length of the string. Some types will allocate the maximum memory in the database even if it is empty others will only allocate the used space. This may seem like a trivial difference but if you have a large database it can make a huge amount of different if you are using more space than is required. | ||||
| |
| | #6 (permalink) |
| Senior Member Join Date: Oct 2006 Location: NJ
Posts: 1,147
![]() ![]() ![]() | Right...there should be no padding characters if you are under the MySQL limitation(s).
__________________ Web Development |
| |
| | #7 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | It's all a matter of speed vs. size. I believe that fixed length strings are slightly quicker to work with as MySQL knows how to 'jump' through the rows instead of having to find the length of each field and go through it that way. I know, it's a really simplistic description but hopefully you get the idea. |
| |