you need to create an lua function that sends the necessary sql string to the database, this can only be done by editing the source and will compromise your server security
an easier way is to re-design the way characters are named, you would need to right click someone to see their name, would not compromise your game's security and would get more options for name choices, this can be done with tfs .2 and higher, but since this is not what you requested, i will only say goodluck to ya, if you do end up finding a code, giving the ability to edit names in this way is a bad idea >.>..but just imho..
the loophole in the naming system is within the ingame guild-id nicks, you can create multiple guilds within the function doPlayerSetGuildNick as well as a larger character name design >.>...i won't go into detail, but this is how i would overcome this obstacle as well as bring forth a nostalgic feeling of the original tibia <3
(this needs no source editing but simple configuration edits within the account maker and settings of the database), have fun, ciao~