i don't know mysql very much. And i've problem about that. I've a database and it's 20 GB. I want to combine 4 columns and then move the combined column to the new one. But the problem is duplicated data in the table.
For example i wanna combine;
Column2(Some of them null, some of them not null),
Column4(Some of them null, some of them not null).
INSERT INTO my_table (new_content)
FROM my_table WHERE my_table > 0;
Create the column in already existing table:
ALTER TABLE my_table ADD COLUMN new_content VARCHAR(55);
Update table and concate all the columns to the newly created column:
UPDATE my_table SET new_content = CONCAT(Column1, Column2);
Create a trigger for all inserting values in future as well:
CREATE TRIGGER insert_trigger BEFORE INSERT ON my_table FOR EACH ROW SET new.new_content = CONCAT(Column1, Column2);
You can also create a trigger for UPDATE:
CREATE TRIGGER BEFORE UPDATE ON my_table FOR EACH ROW SET new.new_content = CONCAT(Column1, Column2);