Skip to content
Tanveer Munavar edited this page May 10, 2020 · 9 revisions
  1. Create the database

create database demodb;

  1. Connect to the database

postgres=> \c demodb

  1. Load the SQL file

demodb=> \i ddl_logging.sql

Output :

CREATE TABLE
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE EVENT TRIGGER
CREATE EVENT TRIGGER
CREATE EVENT TRIGGER
  1. Create a table

CREATE TABLE t1(id int);

  1. DDL operation is captured in the log_ddl table
demodb=> select * from log_ddl;
-[ RECORD 1 ]---+------------------------------
id              | 21
tag             | CREATE TABLE
event           | ddl_command_start
object_type     | none
schema_name     | none
object_name     | none
object_identity | none
pid             | 25930
txid            | 2311810
client_addr     | 172.16.64.65
username        | mohamedt
time            | 2020-05-10 21:49:59.548497+00
-[ RECORD 2 ]---+------------------------------
id              | 22
tag             | CREATE TABLE
event           | ddl_command_end
object_type     | table
schema_name     | public
object_name     | none
object_identity | public.t1
pid             | 25930
txid            | 2311810
client_addr     | 172.16.64.65
username        | mohamedt
time            | 2020-05-10 21:49:59.548497+00
Clone this wiki locally