Say I have a column of type VARCHAR(32)
in a mySQL database.
On Spetmeber 1st I decide to store the string "tea"
, but on September 2nd I decide to update it to "coffee"
.
Clearly, if all the records in this table were squished right up against each other, and we tried to lengthen one record by 3 bytes, then all the records that appeared after this one would need to shift down by 3 bytes. Of course, this is ridiculous; there is no way any DBMS would ever resort to shifting thousands of possible entries.
So what exactly does mySQL do in this eventuality? Does it behave the same way for TEXT and BLOB types?
EDIT: After reading this a day later, I realized that this question was fairly ambiguous. Here is an example that I hope will clear things up:
Say I have a table, fav_drinks
with two columns:
user_id
, which is anINTEGER
drink
, which is aVARCHAR(32)
Pretend that this table is stored like this in memory:
[1,"juice",2,"tea",3,"soda",4,"hot chocolate"]
That is, all records are stored sequentially one after the other. If we need to update user 2's favourite drink from "tea"
to "coffee"
, in theory we would need to shift down the entries for users 3 and 4. Of course, I don't think this is what would happen in a real database.
So, to reiterate the question, how does mySQL manage this specific case where one table entry suddenly requires more memory?
ext
file system. Anyways, this is how I predict it to work, not sure if this is how they actually do it.