Skip to content
Advertisement

How to record who edited a table in my sql

Is there a function to automatically update a column specifying who created a new record in a sql table?

Something similar to the timestamp, but that instead of the time it shows the user who has added the record.

e.g.

Advertisement

Answer

with MySQL itself you cannot do it. The only user known by MySql is the current_user() which the application uses to connect.

you can create Trigger in order to save this user but I believe this does not worth much

Another option is to pass current_user from your application using your Data Access Layer, but this is unrelated with MySql itself and it is Application Logic.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement