I want to create a trigger that will show which table(s) has/have been modified and who (which users) changed the data on this table.
I found out the query below lists all tables that was modified in the last 30 days by ALTER statement but it didn't work out:
select schema_name(schema_id) as schema_name,
name as table_name,
create_date,
modify_date
from sys.tables
where modify_date > DATEADD(DAY, -30, CURRENT_TIMESTAMP)
order by modify_date desc;
It showed error ORA-00942 Table or View not available.
This is the link with the similar question but for MySQL: enter link description here
@rjh @Ike Walker could you please help how to do the query using SQL Tools 1.8?
Should I use oracle Audit on the trigger to do this? I'm using SQL Tools 1.8 b38.
I have created a new table:
This is the query I used to make the table:
CREATE TABLE nag_Historic (
id NUMBER(10) NOT NULL,
tst_date DATE DEFAULT SYSDATE NOT NULL,
Ändere VARCHAR2(20) DEFAULT USER NOT NULL,
title VARCHAR2(100) NOT NULL
);
ALTER TABLE nag_Historic
ADD (
CONSTRAINT nag_pk PRIMARY KEY (id)
);
CREATE SEQUENCE nag_id START WITH 1 INCREMENT BY 1;
I have also made the trigger:
CREATE OR REPLACE TRIGGER trg_nag_histry
BEFORE INSERT OR UPDATE OR DELETE ON nag_historic
FOR EACH ROW
BEGIN
SELECT nag_ID.nextval
INTO :new.id
FROM dual;
END;
This is how I inserted the value:
INSERT INTO nag_Historic (title)
VALUES ('johan');
I have figured out this query for the audit:
SELECT * FROM DBA_STMT_AUDIT_OPTS;
SELECT * FROM dba_priv_audit_opts;
But that still doesn't show which tables have been modified (changed). Please help me, I'm totally stuck.