SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE audit_log ( id SERIAL PRIMARY KEY, user_name TEXT, action TEXT, old_value JSONB, new_value JSONB, action_time TIMESTAMP DEFAULT NOW() ); CREATE OR REPLACE FUNCTION audit_trigger() RETURNS TRIGGER AS $$ BEGIN -- Запись информации в таблицу аудита INSERT INTO audit_log (user_name, action, old_value, new_value) VALUES (current_user, TG_OP, row_to_json(OLD), row_to_json(NEW)); RETURN NEW; END; $$ LANGUAGE plpgsql;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear