{"id":1729,"date":"2025-01-15T11:18:13","date_gmt":"2025-01-15T04:18:13","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=1729"},"modified":"2025-01-15T20:24:57","modified_gmt":"2025-01-15T13:24:57","slug":"postgresql-event-triggers","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/","title":{"rendered":"PostgreSQL Event Triggers"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='overview-of-postgresql-event-triggers'>Overview of PostgreSQL Event Triggers <a href=\"#overview-of-postgresql-event-triggers\" class=\"anchor\" id=\"overview-of-postgresql-event-triggers\" title=\"Anchor for Overview of PostgreSQL Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>Regular <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-triggers\/\">triggers<\/a> are associated with a table and respond to events that occur on the table, such as <code><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-insert\/\">INSERT<\/a><\/code>, <code><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-update\/\">UPDATE<\/a><\/code>, <code><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-delete\/\">DELETE<\/a><\/code>, and <code><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-truncate-table\/\">TRUNCATE<\/a><\/code>.<\/p>\n\n\n\n<p>Unlike regular triggers, event triggers are not associated with a table but a database. Event triggers respond to the database schema change events such as adding a column, dropping a table and so on.<\/p>\n\n\n\n<p>In PostgreSQL, event triggers can track the following events:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ddl_command_start<\/code>: fires at the start of any DDL command.<\/li>\n\n\n\n<li><code>ddl_command_end<\/code>: fires at the end of any DDL command.<\/li>\n\n\n\n<li><code>sql_drop<\/code>: fires after objects are dropped.<\/li>\n\n\n\n<li><code>table_rewrite<\/code>: fires when a change in the table&#8217;s structure occurs.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='creating-event-triggers'>Creating Event Triggers <a href=\"#creating-event-triggers\" class=\"anchor\" id=\"creating-event-triggers\" title=\"Anchor for Creating Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>You can create event triggers using the <code>CREATE EVENT TRIGGER<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> trigger_name\n<span class=\"hljs-keyword\">ON<\/span> event_name\n<span class=\"hljs-keyword\">WHEN<\/span> condition\n<span class=\"hljs-keyword\">EXECUTE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> function_name();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>trigger_name<\/code>: The event trigger name.<\/li>\n\n\n\n<li><code>event_name<\/code>: The DDL event to monitor, such as <code>ddl_command_start<\/code>.<\/li>\n\n\n\n<li><code>condition<\/code>: Optional condition to filter events.<\/li>\n\n\n\n<li><code>function_name<\/code>: The function to execute when the event occurs.<\/li>\n<\/ul>\n\n\n\n<p>In practice, you&#8217;ll find event triggers useful for the following scenarios:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Auditing database schema changes.<\/li>\n\n\n\n<li>Enforcing specific database policies.<\/li>\n\n\n\n<li>Preventing unauthorized database schema modifications.<\/li>\n\n\n\n<li>Automating notifications or logs for administrative purposes.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='example-of-event-triggers'>Example of Event Triggers <a href=\"#example-of-event-triggers\" class=\"anchor\" id=\"example-of-event-triggers\" title=\"Anchor for Example of Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>First, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-create-table\/\">create a table<\/a> called <code>event_logs<\/code> to store the logs of all database structure modifications:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> event_logs (\n    id <span class=\"hljs-type\">INT<\/span> <span class=\"hljs-keyword\">GENERATED<\/span> <span class=\"hljs-keyword\">ALWAYS<\/span> <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> <span class=\"hljs-keyword\">PRIMARY KEY<\/span>,\n    event_type <span class=\"hljs-type\">VARCHAR<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    command_tag <span class=\"hljs-type\">VARCHAR<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    object_id <span class=\"hljs-type\">OID<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    object_name <span class=\"hljs-type\">VARCHAR<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    <span class=\"hljs-built_in\">schema_name<\/span> <span class=\"hljs-type\">VARCHAR<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    user_name <span class=\"hljs-type\">VARCHAR<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    event_time <span class=\"hljs-type\">TIMESTAMPTZ<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span> <span class=\"hljs-keyword\">DEFAULT<\/span> NOW()\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIFRBQkxFIGV2ZW50X2xvZ3MgKCBpZCBJTlQgR0VORVJBVEVEIEFMV0FZUyBBUyBJREVOVElUWSBQUklNQVJZIEtFWSwgZXZlbnRfdHlwZSBWQVJDSEFSIE5PVCBOVUxMLCBjb21tYW5kX3RhZyBWQVJDSEFSIE5PVCBOVUxMLCBvYmplY3RfaWQgT0lEIE5PVCBOVUxMLCBvYmplY3RfbmFtZSBWQVJDSEFSIE5PVCBOVUxMLCBzY2hlbWFfbmFtZSBWQVJDSEFSIE5PVCBOVUxMLCB1c2VyX25hbWUgVkFSQ0hBUiBOT1QgTlVMTCwgZXZlbnRfdGltZSBUSU1FU1RBTVBUWiBOT1QgTlVMTCBERUZBVUxUIE5PVygpICk7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Second, <a href=\"https:\/\/www.pgtutorial.com\/plpgsql\/plpgsql-functions\/\">create a function<\/a> that inserts DDL events into the <code>event_logs<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> log_events()\n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-type\">EVENT_TRIGGER<\/span>\n<span class=\"hljs-keyword\">AS<\/span> \n$$<span class=\"pgsql\">\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> event_logs (\n        event_type,\n        command_tag,\n        object_id,\n        object_name,\n        <span class=\"hljs-built_in\">schema_name<\/span>,\n        user_name\n    )\n    <span class=\"hljs-keyword\">SELECT<\/span>\n        <span class=\"hljs-built_in\">tg_event<\/span>,\n        <span class=\"hljs-built_in\">tg_tag<\/span>,\n        objid,\n        object_identity,\n        <span class=\"hljs-built_in\">schema_name<\/span>,\n        <span class=\"hljs-built_in\">current_user<\/span>\n    <span class=\"hljs-keyword\">FROM<\/span> pg_event_trigger_ddl_commands();\n<span class=\"hljs-keyword\">END<\/span>;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> plpgsql;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIE9SIFJFUExBQ0UgRlVOQ1RJT04gbG9nX2V2ZW50cygpClJFVFVSTlMgRVZFTlRfVFJJR0dFUgpBUyAKJCQKQkVHSU4KICAgIElOU0VSVCBJTlRPIGV2ZW50X2xvZ3MgKAogICAgICAgIGV2ZW50X3R5cGUsCiAgICAgICAgY29tbWFuZF90YWcsCiAgICAgICAgb2JqZWN0X2lkLAogICAgICAgIG9iamVjdF9uYW1lLAogICAgICAgIHNjaGVtYV9uYW1lLAogICAgICAgIHVzZXJfbmFtZQogICAgKQogICAgU0VMRUNUCiAgICAgICAgdGdfZXZlbnQsCiAgICAgICAgdGdfdGFnLAogICAgICAgIG9iamlkLAogICAgICAgIG9iamVjdF9pZGVudGl0eSwKICAgICAgICBzY2hlbWFfbmFtZSwKICAgICAgICBjdXJyZW50X3VzZXIKICAgIEZST00gcGdfZXZlbnRfdHJpZ2dlcl9kZGxfY29tbWFuZHMoKTsKRU5EOwokJCBMQU5HVUFHRSBwbHBnc3FsOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Third, create an event trigger and associate it with the <code>log_events<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> log_schema_changes\n<span class=\"hljs-keyword\">ON<\/span> ddl_command_end\n<span class=\"hljs-keyword\">EXECUTE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> log_events();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIEVWRU5UIFRSSUdHRVIgbG9nX3NjaGVtYV9jaGFuZ2VzCk9OIGRkbF9jb21tYW5kX2VuZApFWEVDVVRFIEZVTkNUSU9OIGxvZ19ldmVudHMoKTs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Fourth, modify the <code>products<\/code> table by <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table-add-column\/\">adding a new column<\/a> called <code>net_weight<\/code> with the type <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-decimal\/\">decimal<\/a>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> net_weight <span class=\"hljs-type\">DEC<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUREIENPTFVNTiBuZXRfd2VpZ2h0IERFQzs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>The <code>ALTER TABLE<\/code> statement will fire the <code>log_schema_changes<\/code> trigger that <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-insert\/\">inserts data<\/a> into the <code>event_logs<\/code> table.<\/p>\n\n\n\n<p>Finally, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-select\/\">retrieve data<\/a> from the <code>event_logs<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  event_type,\n  command_tag,\n  object_name,\n  user_name\n<span class=\"hljs-keyword\">FROM<\/span>\n  event_logs;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIGV2ZW50X3R5cGUsIGNvbW1hbmRfdGFnLCBvYmplY3RfbmFtZSwgdXNlcl9uYW1lIEZST00gZXZlbnRfbG9nczs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">   event_type    | command_tag |   object_name   | user_name\n<span class=\"hljs-comment\">-----------------+-------------+-----------------+-----------<\/span>\n ddl_command_end | <span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> | <span class=\"hljs-built_in\">public<\/span>.products | postgres<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='listing-event-triggers'>Listing Event Triggers. <a href=\"#listing-event-triggers\" class=\"anchor\" id=\"listing-event-triggers\" title=\"Anchor for Listing Event Triggers.\">#<\/a><\/h2>\n\n\n\n<p>To get all event triggers, you can query from the <code>pg_event_trigger<\/code> in the PostgreSQL system catalogs:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> pg_event_trigger;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUICogRlJPTSBwZ19ldmVudF90cmlnZ2VyOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">  <span class=\"hljs-type\">oid<\/span>  |      evtname       |    evtevent     | evtowner | evtfoid | evtenabled | evttags\n<span class=\"hljs-comment\">-------+--------------------+-----------------+----------+---------+------------+---------<\/span>\n <span class=\"hljs-number\">46763<\/span> | log_schema_changes | ddl_command_end |       <span class=\"hljs-number\">10<\/span> |   <span class=\"hljs-number\">46762<\/span> | O          |<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='disabling-event-triggers'>Disabling Event Triggers <a href=\"#disabling-event-triggers\" class=\"anchor\" id=\"disabling-event-triggers\" title=\"Anchor for Disabling Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>To turn off an event trigger, you use the <code>ALTER EVENT TRIGGER<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> event_trigger_name\n<span class=\"hljs-keyword\">DISABLE<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement turns off the <code>log_schema_changes<\/code> event trigger:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> log_schema_changes\n<span class=\"hljs-keyword\">DISABLE<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=QUxURVIgRVZFTlQgVFJJR0dFUiBsb2dfc2NoZW1hX2NoYW5nZXMgRElTQUJMRTs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='enabling-event-triggers'>Enabling Event Triggers <a href=\"#enabling-event-triggers\" class=\"anchor\" id=\"enabling-event-triggers\" title=\"Anchor for Enabling Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>To enable an event trigger, you also use the <code>ALTER EVENT TRIGGER<\/code> statement but with the <code>ENABLE<\/code> option:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> event_trigger_name\n<span class=\"hljs-keyword\">ENABLE<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement re-enables the <code>log_schema_changes<\/code> event trigger:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> log_schema_changes\n<span class=\"hljs-keyword\">ENABLE<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=QUxURVIgRVZFTlQgVFJJR0dFUiBsb2dfc2NoZW1hX2NoYW5nZXMgRU5BQkxFOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='removing-event-triggers'>Removing Event Triggers <a href=\"#removing-event-triggers\" class=\"anchor\" id=\"removing-event-triggers\" title=\"Anchor for Removing Event Triggers\">#<\/a><\/h2>\n\n\n\n<p>If you no longer use an event trigger, you can drop it using the <code>DROP EVENT TRIGGER<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> event_trigger_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, you can use the following statement to drop the <code>log_schema_changes<\/code> event trigger:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> log_schema_changes;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=RFJPUCBFVkVOVCBUUklHR0VSIGxvZ19zY2hlbWFfY2hhbmdlczs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='preventing-unauthorized-schema-changes'>Preventing unauthorized schema changes <a href=\"#preventing-unauthorized-schema-changes\" class=\"anchor\" id=\"preventing-unauthorized-schema-changes\" title=\"Anchor for Preventing unauthorized schema changes\">#<\/a><\/h2>\n\n\n\n<p>The following example shows how to use an event trigger to prevent unauthorized users from modifying the database structure:<\/p>\n\n\n\n<p><strong>Step 1<\/strong>. Create a function that only allows the user <code>postgres<\/code> to modify the database structure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> stop_ddl () \n  <span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-type\">EVENT_TRIGGER<\/span> \n<span class=\"hljs-keyword\">AS<\/span> \n$$<span class=\"pgsql\">\n<span class=\"hljs-keyword\">BEGIN<\/span>\n   <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-built_in\">current_user<\/span> &lt;&gt; <span class=\"hljs-string\">'postgres'<\/span> <span class=\"hljs-keyword\">THEN<\/span>\n      <span class=\"hljs-keyword\">RAISE<\/span> <span class=\"hljs-keyword\">EXCEPTION<\/span> <span class=\"hljs-string\">'The user % does not have the authorization to change the database structure'<\/span>, <span class=\"hljs-built_in\">current_user<\/span>;\n   <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">IF<\/span>;\n<span class=\"hljs-keyword\">END<\/span>;\n$$<\/span> \n<span class=\"hljs-keyword\">LANGUAGE<\/span> plpgsql;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIEZVTkNUSU9OIHN0b3BfZGRsICgpIAogIFJFVFVSTlMgRVZFTlRfVFJJR0dFUiAKQVMgCiQkCkJFR0lOCiAgIElGIGN1cnJlbnRfdXNlciA8PiAncG9zdGdyZXMnIFRIRU4KICAgICAgUkFJU0UgRVhDRVBUSU9OICdUaGUgdXNlciAlIGRvZXMgbm90IGhhdmUgdGhlIGF1dGhvcml6YXRpb24gdG8gY2hhbmdlIHRoZSBkYXRhYmFzZSBzdHJ1Y3R1cmUnLCBjdXJyZW50X3VzZXI7CiAgIEVORCBJRjsKRU5EOwokJCAKTEFOR1VBR0UgcGxwZ3NxbDs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>The <code>stop_ddl<\/code> function <a href=\"https:\/\/www.pgtutorial.com\/plpgsql\/plpgsql-exception\/\">raises an exception<\/a> if the user is not <code>postgres<\/code>.<\/p>\n\n\n\n<p><strong>Step 2<\/strong>. Create a event trigger <code>authorize_schema_change<\/code> that executes the <code>stop_ddl()<\/code> function whenvever a DDL event occurs:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">EVENT TRIGGER<\/span> stop_executing_ddl \n<span class=\"hljs-keyword\">ON<\/span> ddl_command_start\n<span class=\"hljs-keyword\">EXECUTE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> stop_ddl();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIEVWRU5UIFRSSUdHRVIgc3RvcF9leGVjdXRpbmdfZGRsIE9OIGRkbF9jb21tYW5kX3N0YXJ0CkVYRUNVVEUgRlVOQ1RJT04gc3RvcF9kZGwgKCk7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Only the user postgres can execute DDL commands, while others will receive an exception.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PostgreSQL event triggers are database-level triggers.<\/li>\n\n\n\n<li>Use PostgreSQL event triggers for monitoring and controlling database structure changes.<\/li>\n\n\n\n<li>Use the <code>CREATE EVENT TRIGGER<\/code> statement to create a new event trigger.<\/li>\n\n\n\n<li>Use the <code>ALTER EVENT TRIGGER ... DISABLE<\/code> statement to disable an event trigger.<\/li>\n\n\n\n<li>Use the <code>ALTER EVENT TRIGGER ... ENABLE<\/code> statement to enable an event trigger.<\/li>\n\n\n\n<li>Use the <code>DROP EVENT TRIGGER<\/code> statement to remove an event trigger from a database.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1729\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Event Triggers\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1729\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Event Triggers\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you&#8217;ll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations. Overview of PostgreSQL Event Triggers # Regular triggers are associated with a table and respond to events that occur on the table, such as INSERT, UPDATE, DELETE, and TRUNCATE. Unlike regular triggers, event [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":100,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1729","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL Event Triggers<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL Event Triggers\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-15T13:24:57+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-event-triggers\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-event-triggers\\\/\",\"name\":\"PostgreSQL Event Triggers\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2025-01-15T04:18:13+00:00\",\"dateModified\":\"2025-01-15T13:24:57+00:00\",\"description\":\"In this tutorial, you'll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-event-triggers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-event-triggers\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-event-triggers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Tutorial\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL Event Triggers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL Event Triggers","description":"In this tutorial, you'll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL Event Triggers","og_description":"In this tutorial, you'll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-01-15T13:24:57+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/","url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/","name":"PostgreSQL Event Triggers","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2025-01-15T04:18:13+00:00","dateModified":"2025-01-15T13:24:57+00:00","description":"In this tutorial, you'll learn how to use the PostgreSQL event triggers to monitor and control Data Definition Language (DDL) operations.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-event-triggers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Tutorial","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL Event Triggers"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=1729"}],"version-history":[{"count":7,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1729\/revisions"}],"predecessor-version":[{"id":1746,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1729\/revisions\/1746"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=1729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}