What's the most efficient way of truncating the names in a first_name and last_name column to 1 character?

Tenthrow :

What's the most efficient way of truncating the names in a first_name and last_name column to 1 character?

I have a mysql database that I want to hand off to a developer but I want to partially sanitize the data so that the two name records drop down to just initials.

I tried to modify the varchar to 1 character but mysql will not let me truncate the data, it just throws an error. I am working from a dump of the database before I hand it off. I want to obscure the names without making them all the same.

Kevin :
update tablename set first_name=left(first_name, 1), last_name = left(last_name, 1)

But, as Gordon Linoff mentioned, this could be expensive if you have a lot of rows in the table

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=195334&siteId=1