简体   繁体   中英

using mysql how to insert rows in audit table?

I am new to mysql, I have two table employee and audit

  1. employee Table have 4 columns

    1. id
    2. name
    3. sal
    4. role
  2. audit Table have 7 columns

    1. id
    2. type
    3. old_value
    4. new_value
    5. date
    6. username

Here , I want to insert 3 rows in audit table if someone add one row in employee table. To maintain the history

for eg: I made an entry in employee table

John | 20,000 | anaylst

Than my audit table will be

Type  | old_value |new_value | date        | username  
  name|           |John      | 01/04/2015  | dummy1
   sal|           |20,000    | 01/04/2015  | dummy1
 role |           |anaylst   | 01/04/2015  | dummy1

I am unable to insert rows in audit table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM