Consider you have table USER
which has primary key on field USER_ID
. And every table in your db should contain MODIFIED_BY
field with id of actual user. My aim is to specify default value on that field which equals id of user with appropriate name. F.E. you have user with name system
and you want every record of every table to have id of this user in MODIFIED_BY
field. As well you want all the new records to satisfy this.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- sqlyog export query result as csv
Assuming that you are referring to other sorts of users than database users (e.g. 'registered users'), maybe triggers are the solution to your problem. With two triggers, one fired when inserting and one when updating, you can specify the value of a
modified_at
-column using custom code, e.g.select user_id from ... where ...
Please check the following sample code, which should directly answer your question; hope it solves your problem. Otherwise, please give us more information / some more context.