Posted by Guest memeber “Dipon”
MySQL Database, Text Field index can’t be selected as Unique. So checking duplicate data insert on text flied, its make resource usage high. For prevent duplicate data insert in text and reduce database usage, also the resource, I have to find alternative solution.
Its so easy. I add a extra field on database like name hash make it VARCHAR (255) and Index give unique. I covert all text in md5(“Your String”) and insert in hash field and original string on text field.
Below is example.
CREATE TABLE `post` (
...................................,
......................................,
`post_data` text NOT NULL,
`hash` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `hash` (`hash`)
);
Insert SQL:
INSERT INTO `post` ( ............, ..........., `post_data`, ..........., `hash`) VALUES ( NULL , ............, ............, 'Test Text', ............, 'e0adbcccc2055d976bfe3d6113c2f1d4', );
Posted by Guest memeber “Dipon”. He is a web application architect. He loves to develop php and mySql base web applications.
Incoming search terms:
- mysql automatic unqiue text (1)



May 15th, 2010
Frank Boros
Posted in
Tags: 





great info thanks