Sunday, 21 January 2024

PostgreSQL: Log the DROP TABLE Statement

 How to log the DROP TABLE Statement in the log file of PostgreSQL?

Above is a common question/suggestion by the PostgreSQL DBA. We should log all the type of statements like DDL, DML. But DDL is most important than DML logging.

For logging the DDL statement into log files, we should change the following parameters in the postgresql.conf file.

log_statement=’ddl’
log_line_prefix = ‘%t %c %u ‘ (time, sessionid, user)
logging_collector = ON

For example:
I dropped a tbl_student table. Now, I can see below the line in my log file.

No comments:

Post a Comment

Master and Slave - Sync check - PostgreSQL

  1) Run the below Query on Primary:- SELECT     pid,     usename,     application_name,     client_addr,     state,     sync_state,     sen...