sql - MySQL truncation command - unicode characters -
I am currently trying to adjust the value stored in the table in MySQL, there was a series of unicode characters stored in the values is. I need to cut the cost of 40 bytes of storage, but when I try:
UPDATE 'MYTABLE SET' MYCOLUMN = LEFT (`MYCOLUMN`, 40);
MySQL is highly helpful and retains bytes instead of 40 <40> <40> .
Gacien
I'm not sure if you actually sort by 40 bytes Want to
Because you can disturb the Unicode characters, the condition "The last character of maximum 40 bytes is still valid."
I will write an archived function for this. I'm not sure this works, but I think you catch my drift:
DELIMITER & amp; Amp; Create a function matriculate (topic VARCHAR (255) character set UTF8, max_bytes INT unassigned) Returns on VARCHAR (255) Character set UTF 8 Start defragment DECLARE byte_len INT; DECLARE char_len INT; DECLARE RES VARCHAR (255) Character set utf8; SET RES = LEFT (subject, max_byte); SET byte_len = BIT_LENGTH (RES) / 8; SET char_len = CHAR_LENGTH (RES); WHYLE byte_len & gt; Max_bytes DO SET char_len = char_len - 1; SET RES = LEFT (res, char_len); SET byte_len = BIT_LENGTH (RES) / 8; In the end; Return ridge; Finally & amp; & Amp; & Amp; DELIMITER;
Comments
Post a Comment