Auditing objects v17
Object-level auditing allows selective auditing of objects for specific data manipulation language (DML) statements, such as SELECT
, UPDATE
, DELETE
, and INSERT
, on a given table. Object-level auditing also lets you include or exclude specific groups by specifying (@)
or (-)
with the edb_audit_statement
parameter. For more information about DML statements, see Selecting SQL statements to audit.
Use the following syntax to specify an edb_audit_statement
parameter value for SELECT
, UPDATE
, DELETE
, or INSERT
statements:
{ select | update | delete | insert }{@ | -}groupname
Example
In this example, edb_audit_connect
and edb_audit_statement
are set with the following non-default values:
logging_collector = 'on' edb_audit_connect = 'all' edb_audit = 'csv' edb_audit_statement = 'select, insert, update, delete'
The SQL statements invoked by the SELECT
, INSERT
, UPDATE
, and DELETE
commands are audited.
The following is the database session that occurs:
$ psql edb enterprisedb Password for user enterprisedb: psql.bin (17.2.0) Type "help" for help. edb=# SHOW edb_audit_connect;
edb_audit_connect ------------------- all (1 row)
edb=# SHOW edb_audit_statement;
edb_audit_statement -------------------------------- select, insert, update, delete (1 row) edb=# CREATE TABLE emp edb-# (empno NUMBER(4) NOT NULL, edb(# ename VARCHAR2(10), edb(# job VARCHAR2(9), edb(# mgr NUMBER(4), edb(# hiredate DATE, edb(# sal NUMBER(7, 2), edb(# comm NUMBER(7, 2), edb(# deptno NUMBER(2)); CREATE TABLE edb=# ALTER TABLE emp SET (edb_audit_group = 'low_security'); ALTER TABLE edb=# CREATE TABLE dept edb-# (deptno NUMBER(2), edb(# dname VARCHAR2(14), edb(# loc VARCHAR2(13) ) with (edb_audit_group = 'low_security'); CREATE TABLE edb=# CREATE TABLE bonus edb-# (ename VARCHAR2(10), edb(# job VARCHAR2(9), edb(# sal NUMBER, edb(# comm NUMBER) with (edb_audit_group = 'high_security'); CREATE TABLE edb=# CREATE TABLE sal edb-# (grade NUMBER, edb(# losal NUMBER, edb(# hisal NUMBER) with (edb_audit_group = 'high_security'); CREATE TABLE edb=# SET edb_audit_statement = 'select@low_security@high_security, insert@high_security-low_security, update-low_security@high_security, delete@low_security-high_security'; SET
edb=# SELECT reloptions FROM pg_class WHERE relname IN('emp', 'dept', 'bonus', 'sal');
reloptions --------------------------------- {edb_audit_group=low_security} {edb_audit_group=low_security} {edb_audit_group=high_security} {edb_audit_group=high_security} (4 rows)
edb=# SELECT setting FROM pg_settings WHERE name = 'edb_audit_statement';
setting -------------------------------------------------------------------------------------------------------------------------------------------- select@low_security@high_security, insert@high_security-low_security, update-low_security@high_security, delete@low_security-high_security (1 row)
edb=# SELECT * FROM emp;
empno | ename | job | mgr | hiredate | sal | comm | deptno -------+-------+-----+-----+----------+-----+------+-------- (0 rows)