mysql Set default value of a column as the current logged in user
OK, this is generally not the way one creates audit tables. Typically, when you want to log inserts, deletes, and updates, you would do something like this:
Create a table like foo:
create table foo (
foo_id int not null auto_increment primary key,
foo_data varchar(100) not null
);
Then you usually make an audit table like so:
create table foo_audit (
foo_audit_id not null auto_increment primary key,
foo_id int,
foo_data varchar(100),
change_type char(1),
change_timestamp timestamp default current_timestamp,
change_login varchar(100)
);
Then you make a trigger or triggers on the table like so:
create trigger trg_foo_insert
after insert on foo
for each row
insert into foo_audit (
foo_id,
foo_data,
change_type,
change_login
)
values (
new.foo_id,
new.foo_data,
'I',
current_user
);
You would make a "U" trigger for updates, and a "D" trigger for deletes.
I think the main problem you are having is you are trying to do a "one size fits all" audit table; I think this pattern will cause you a lot of issues, you don't necessarily have the data you're looking for, and you will still need to write at least one trigger for each table you are auditing.
The actual answer to your question, however, is that you were either setting a trigger on a table that was not being inserted to, or trying to update a column on a table where the column did not exist.